Forum Moderators: coopster
An example is
$ar = array(
'new_user' => 'newuser.php',
'tst1' => array(
'subtst' => 'subtstlink.php',
'subtst2' => 'sublink2.php'
),
'heyhey' => 'heyhey.php',
);
I am wondering what is the best way to store that in a mysql database (Both the item name and the link to it). Is there any php function that will allow me to make such an array into some sort of variable (String?) which can then be read easilly and made back into the array for manipulation and creation of the tree menu?
Best Regards
NooK
This works for me
$array=array("dog","cat","frog's");
$arrayString=serialize($array)
$arrayString=htmlentities($arrayString,ENT_QUOTES);
mysql_query...// insert your string into the db.
Then when fetching the string and converting it back to an array.
$result=mysql....
$row=mysql_fetch_array($result);
$arrayString=html_entity_decode($row['FieldName'],ENT_QUOTES);
$array=unserialize($arrayString);
and that should be that.