I don't know what I have done wrong with the code below but it is not working.
if($_data_count = count($_csv_raw_array) > 0){
foreach($_csv_raw_array as $_csv_row){
array_push($this->_data, array_map(call_user_func(array($this, 'replace')), $_csv_row));
}
return $this->result(true, 'CSV parsing done.', '', $this->_data);
}
// And the replace function is:
private function replace($_value){
return preg_match('/(\r\n|\n|\r)/', $_value) ? '' : $_value;
}
But I don't know why it is not working and throws an exception:
A PHP Error was encountered
Severity: Warning
Message: Missing argument 1 for Import::replace()
Filename: libraries/Import.php
Line Number: 116
Basically what I wanted to to here is import a CSV file which I already imported, now I want to replace any new line characters that is present within the array to be replaced with empty (nothing). But every time I execute this code it throws an exception. Can you people out there suggest. Please.
Thanx