NYCPHP Meetup

NYPHP.org

[nycphp-talk] Unseralize help needed.

drydell at optonline.net drydell at optonline.net
Fri Nov 6 12:59:11 EST 2009


$new_fred is an array... that's exactly what you'd get if you echo an array. Try var_dump($new_fred) or print_r($new_fred) and you'll see what's in the array... ----- Original Message -----From: "Hall, Leam" Date: Friday, November 6, 2009 12:50 pmSubject: [nycphp-talk] Unseralize help needed.To: NYPHP Talk > Morning all!> > I've been working on the "pull an array from a file" again and > trying to implement the "unserialize" suggestion. Cant seem to > make it work. Here's the draft:> > ####> > echo "fred";> $my_info = array('me' => 'mi', 'myself' => 'numerouno',  'i' => > 'id' );> $fred = serialize($my_info);> $my_file = fopen( '/tmp/me.ser', 'w');> fwrite($my_file, $fred);> fclose($my_file);> echo " $fred.";> $new_fred = array();> $new_fred_line = file_get_contents('/tmp/me.ser');> echo "$new_fred_line is here.";> $new_fred = unserialize($new_fred_line);> $new_fred_me = $new_fred['me'];> echo " new_fred is $new_fred. ";> > ####> > Produces:> > ####> > fred > a:3:{s:2:"me";s:2:"mi";s:6:"myself";s:9:"numerouno";s:1:"i";s:2:"id";}. > a:3:{s:2:"me";s:2:"mi";s:6:"myself";s:9:"numerouno";s:1:"i";s:2:"id";} is here. > new_fred is Array. > > ####> > Trying to get $new_fred to be an array and duplicate of > $my_info. Thoughts?> Leam> 
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.nyphp.org/pipermail/talk/attachments/20091106/3b54a72a/attachment.html>


More information about the talk mailing list