[ create a new paste ] login | about

Link: http://codepad.org/Ry98mDDg    [ raw code | output | fork ]

PHP, pasted on Sep 19:
<?php

$str = '
{
    "alert": "success",
    "content": [
        {
            "id": "HIDDEN",
            "answers": {
                "3": {
                    "text": "Name",
                    "type": "control_textbox",
                    "answer": "Tim"
                },
                "4": {
                    "text": "Telephone Number",
                    "type": "control_textbox",
                    "answer": "07791906023"
                }
            }
        }
    ]
}
';

$submissions = json_decode($str, TRUE); //associative array instead of normal object

print "Status: ". $submissions['alert']."\n\n";

foreach ($submissions['content'][0]['answers'] as $submission) {
	print $submission["text"]."\n"; 
}


Output:
1
2
3
4
Status: success

Name
Telephone Number


Create a new paste based on this one


Comments: