note 73940 added to function.eval

From: Date: Fri, 16 Mar 2007 11:06:21 +0000
Subject: note 73940 added to function.eval
Groups: php.notes 
Request: Send a blank email to php-notes+get-124507@lists.php.net to get a copy of this message
Since JSON started becoming popular. I've started applying the same idea to PHP arrays. Its an alternative to using XML or CSV. For example: <?php $from_external_source = '( "a" => "1", "b" => array( "b1" => "2", "b2" => "3" ) )'; eval( '$external_source_as_array = array'.$from_external_source.';' ); if ( is_array( $external_source_as_array ) ) { // now you can work with the external source as an array print_r( $external_source_as_array ); } ?> It can be less verbose than XML, but provide more meta data than CSV, and unlike CSV, data ordering is not an issue. I used it when I wanted to store log data externally in a text file. Kai ---- Server IP: 87.124.64.96 Probable Submitter: 144.178.147.195 ---- Manual Page -- http://www.php.net/manual/en/function.eval.php Edit -- https://master.php.net/note/edit/73940 Del: integrated -- https://master.php.net/note/delete/73940/integrated Del: useless -- https://master.php.net/note/delete/73940/useless Del: bad code -- https://master.php.net/note/delete/73940/bad+code Del: spam -- https://master.php.net/note/delete/73940/spam Del: non-english -- https://master.php.net/note/delete/73940/non-english Del: in docs -- https://master.php.net/note/delete/73940/in+docs Del: other reasons-- https://master.php.net/note/delete/73940 Reject -- https://master.php.net/note/reject/73940 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#124507) next »