How do I apply a string function to an array?

Posted by ggg on Stack Overflow See other posts from Stack Overflow or by ggg
Published on 2010-04-15T18:33:26Z Indexed on 2010/04/15 22:53 UTC
Read the original article Hit count: 249

Filed under:
|

I was fortunate enough to receive this code (flips Lastname, Firstname) from an earlier post.

$name = "Lastname, Firstname";
$names = explode(", ", $name);
$name = $names[1] . " " . $names[0];

How do I apply the function to each value in an array that is in the form: $ginfo ->$(LastName, FirstName).

I tried the code below, but it doesn't work.

$name1 =($ginfo->White); 
$name1 = explode(", ", $name1);  $FLw = $name1[1] . " " . $name1[0]; 
foreach ($name1 as ($ginfo->White)) {return($FLw);}

© Stack Overflow or respective owner

Related posts about string-manipulation

Related posts about php5