I am not very good with regex myself.
This is why I left it to someebody else to show what to use π
But you know there is a way in php to convert array to string
and back again string to array.
This is same way as is used when $SESSION array is saved in the session file.
This is how values of $SESSION can be remembered from script to script for a user.
The stored session array is written to a file, in format of a string.
The string is read from the file and converted back to an array called $_SESSION.
The 2 functions I am talking about are:
[man]serialize[/man]
[man]unserialize[/man]
<?php
$myarray = array(
'name' => 'henry',
'age' => 22,
'location' => 'england'
);
$string = serialize( $myarray );
echo $string;
echo '<br>';
$newarray = unserialize( $string );
print_r( $newarray );
?>
The variable to serialize need not be an array.
It can be any variable, like
$x = 1234; $x = false; $x = 'Hello world';
Regards