I have data like this in my array first_name, last_name,....
I am looking for an array to replace the _ with a space..is this possible?
I took alook at http://php.net/manual/en/function.array-replace.php but I am not sure if this is what I want.
Just with str_replace
, it takes either strings or arrays in all arguments that matter:
var_dump(str_replace('_',' ',array('foo_bar','lorem_ipsum')));
array(2) {
[0]=>
string(7) "foo bar"
[1]=>
string(11) "lorem ipsum"
}
foreach($array as $key=>$value){
$array[$key]=str_replace("_"," ",$value);
}
That should do it, right?
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.