note 73940 deleted from function.eval by peehaa
| From: | peehaa@php.net | Date: | Mon, 09 Dec 2013 11:56:43 +0000 |
| Subject: | note 73940 deleted from function.eval by peehaa | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-197854@lists.php.net to get a copy of this message | ||
Note Submitter: kai dot chan at kaisystems dot co dot uk
----
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