minus the crap.
I have a field in a MySQL table called ProductName. The values for this field are stored in a serialized array for each record. Each array can contain any number of product names. I know this is a bad way of doing this but for my purposes it will do the job.
The issue I am having is getting the contents of each array to display of a page. Ie, I wish to be able to view the contents of this table including the ProductName field. As most will probably be aware, if you just read in the values for $ProductName, you'll get all the serialized crap that gets stored with it, which I don't want. Therefore you unserialize the data -
$Get_Array = unserialize($ProductName);
This however, is not enough because what will be produced by the above would be 'Array', not what I want to see! I have been experiementing with implode() and explode() but cannot seem to get what I want, (a list of the actual product names). Currently i'm trying to use this code:
$Get_Array = unserialize($ProductName);
$Get_Array_Res = implode(", ",$Get_Array);
However it produces the following when executed:
on, on, on, on1
on, on1
There are two records in the table, one has to product names, the other has four, hense the two 0n's and the four 0n's. What 'on' actually is i'm not sure, something to do with the array data? If I don't use the implode function, I get this in my display page:
'Array'
However I do have a line of code for debugging:
echo "<PRE>", print_r($Get_Array),"</PRE>";
The result of this is:
Array
(
[Product A] => on
[Product B] => on
[Product C] => on
[Product D] => on
)
1
Array
(
[Product A] => on
[Product C] => on
)
1
You can see the product names, as well as the on's! how do I just get the product names, no 'array' no 'ons' just the actual names?
I no this is a bit long winded but I wanted to detail everything as much as poss to avoid confusion!
Any help would be much appreciated.