Help me in this array

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
mianmajidali
Forum Commoner
Posts: 30
Joined: Tue Dec 01, 2009 8:05 pm

Help me in this array

Post by mianmajidali »

$test[]='Products';
$test['Prodcuts']=array('Dell','Acer','HP');

hi to all,
i want to insert ' $test ' into mysql using php, its input will be received by form and will be stored into table.
now this is working with " print_r " and its output is as bellow....
print_r($test);
Array ( [0] => Products [Prodcuts] => Array ( [0] => Dell [1] => Acer [2] => HP ) )
now please guide me how can i insert it into table as single varible and how can i fetch it and use its values into nevigation like...
Products
.Dell
.Acer
.HP

thanks in advance.
cpetercarter
Forum Contributor
Posts: 474
Joined: Sat Jul 25, 2009 2:00 am

Re: Help me in this array

Post by cpetercarter »

Have look at the serialize() function. It is often used to store an array as a single field in a database. The unserialize() function is used to recreate the array when the data is recovered from the database.
User avatar
Jonah Bron
DevNet Master
Posts: 2764
Joined: Thu Mar 15, 2007 6:28 pm
Location: Redding, California

Re: Help me in this array

Post by Jonah Bron »

While serialize() is a very useful function, in this case, you should create a database structure to hold your data. Give us a graphical representation of the kind of data you're trying to store, and we can suggest something.
Post Reply