Hello there,
I am trying to parse some data to create an HTML select control, but am not really too familiar with PHP - can anyone help me out...
Here is a sample of the data...
[{"name":"","value":1,"target":null},{"name":"Bedfordshire","value":2,"target":null},{"name":"Berkshire","value":3,"target":null},{"name":"Buckinghamshire","value":4,"target":null}]
So basically my PHP script needs to echo out the options for my select control.
Many thanks,
Len
Parsing issue
Moderator: General Moderators
- AbraCadaver
- DevNet Master
- Posts: 2572
- Joined: Mon Feb 24, 2003 10:12 am
- Location: The Republic of Texas
- Contact:
Re: Parsing issue
I'll leave the select control to you, but that string is json encoded so this will get you started:
Code: Select all
$objects = json_decode('[{"name":"","value":1,"target":null},{"name":"Bedfordshire","value":2,"target":null},{"name":"Berkshire","value":3,"target":null},{"name":"Buckinghamshire","value":4,"target":null}]');
foreach($objects as $o) {
echo $o->name . ' = ' . $o->value;
}mysql_function(): WARNING: This extension is deprecated as of PHP 5.5.0, and will be removed in the future. Instead, the MySQLi or PDO_MySQLextension should be used. See also MySQL: choosing an API guide and related FAQ for more information.