You're basically asking two questions here - 1) how to get an hierarchical php structure from a db table and 2) how to encode this structure in json. For the first question see, for example, my (old but working) code For the second, I believe simple json_encode will work pretty well.
You're basically asking two questions here - 1) how to get an hierarchical php structure from a db table and 2) how to encode this structure in json. For the first question see, for example, my (old but working) code. For the second, I believe simple json_encode will work pretty well.
Thanks @stereofrog. You are very close to my object. The encoded format is different from required json.
I don't require parent_ID and some additional stuff are coming. – Brij Apr 16 '10 at 5:57.
If you have PHP json extension on your server installed, just use it on an array. The steps will be: Build PHP array with hierarchy based on mysql resutls call a json_encode($array) pl.php.net/manual/en/function.json-encod... If you don't have json_encode enabled on your server and cannot install it... You'll just have to write it by hand. It'll be something like that (untested code warning): function my_json_encode($array) { $return = '{'; $count = count($array); $i = 0; foreach ($array as $key => $val) { $return .
= '"'. $key. '" : '; if (!is_array($val)) $return .
= '"'. $val. '"'; else $return .
= my_json_encode($val); if ($i.
This solution is a simple proof-of-concept and has to be enhanced. To add is, for example, object type support and some error handle. It's better to use json_encode anyway.
– Tomasz StruczyÅ„ski Apr 15 '10 at 9:32 Sorry, one more thing. If you're sending json, remember that you should set appropriate headers in response. Like: header('Content-type: application/json'); – Tomasz StruczyÅ„ski Apr 15 '10 at 9:34 Now my question is how to create nested/hierarchical php array?
– Brij Apr 15 '10 at 9:35.
I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.