I'm trying to replace quotes and others characters from a mysql result array, using strtr() function. But i got Warning: strtr() expects parameter 1 to be string, array given and null values.
Heres my code:
while($rows = mysqli_fetch_assoc($list)){
$string_filter = array(';'=>'','['=>'',']'=>'','{'=>'','}'=>'','"'=>'',"'"=>'');
$data[$rows['id']] = strtr($rows,$string_filter);
}
$data is an array that i want to remove/trim the characters specified in $string_filter array. Heres the content sample from $data:
Array ( [1] => Array ( [id] => 1 [user_id] => 204554 [name] => Rich [group] => PL [ai] => BA [image] => 204554-35849.jpg ) [2] => Array ( [id] => 2 [user_id] => 124534 [name] => James [group] => SS [ai] => IT [image] => 123141-12312.jpg )...
strstr()searches strings, I suspect you're looking forstr_replace().$rows? Your code is confusing, for instance what is$data, and what do you expect your code to return?$datais an array. I want my code to return an array with specified characters in$string_filterremoved.