Re: saving and retrieving an array from a database

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Well it seems like u made a mess there with arrays...

<?
 $first[] = array('appple', 'pear', 'banana');
 $second = serialize($first);
 $third[]= unserialize($second);

 echo $second; //outputs serialized data
 echo $third[1];

?>

>From definition of first I understand it's an array of arrays with
element on position 0 (ZERO) set to an array of apple, pear, banana
elements.
If u serialize it and unserialize it you will obtain same thing...

so at the end of the script you should

echo $third[0];

Andy

ross@xxxxxxxxxxxxx wrote:
> ok this seem to work but how do I bring it back? This is what I have so
> far.
> 
> <?
> $first[] = array('appple', 'pear', 'banana');
> $second = serialize($first);
> $third[]= unserialize($second);
> 
> echo $second; //outputs serialized data
> echo $third[1];
> 
> ?>
> ----- Original Message ----- From: "Peter Lauri" <lists@xxxxxxxxxxx>
> To: "'Ross'" <ross@xxxxxxxxxxxxx>; <php-general@xxxxxxxxxxxxx>
> Sent: Monday, August 07, 2006 8:23 AM
> Subject: RE:  saving and retrieving an array from a database
> 
> 
>> http://se2.php.net/serialize
>>
>> /Peter
>>
>> -----Original Message-----
>> From: Ross [mailto:ross@xxxxxxxxxxxxx]
>> Sent: Monday, August 07, 2006 7:19 PM
>> To: php-general@xxxxxxxxxxxxx
>> Subject:  saving and retrieving an array from a database
>>
>> Hi,
>>
>> I have an array of values. I want to save them with php to a single
>> field in
>>
>> my database and then retrieve them to an array.
>>
>>
>> What is the simplest way to achive this?
>>
>>
>> Ross
>>
>> -- 
>> PHP General Mailing List (http://www.php.net/)
>> To unsubscribe, visit: http://www.php.net/unsub.php
>>
>>
>>
> 

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux