Helping ordinary people create extraordinary websites!
   

PHP array to string?

Sunday, 27th September 2009
by Grant


I would like to convert the values of an array to a string but am not sure which function would allow me to do this.





weaverryan
You've got several choices depending on what you're looking for.

serialize($arr) - turns your array into a string, you can then deserialize() the resulting string to turn in back into an array.

Also, var_export and print_r can both take a boolean true as their second argument so that they will return the value instead of printing it out. So, you could say $str = var_export($arr, true)
Sunday, 27th September 2009
Votes:
31
14