php - populate input fields with JSON Object value -


first off, apologies, not php expert in anyway , struggling this, have entry in db in json format.

i trying extract values object series of input boxes.

after using:

$response = json_decode($row['responsejson']); 

where responsejson name of table, return following object:

stdclass object ( [fields] => stdclass object ( [marketingid] => stdclass object ( [attributes] => stdclass object ( [type] => hidden [id] => marketingid [value] => 0 ) [value] => 7 ) [marketingtelephone] => stdclass object ( [attributes] => stdclass object ( [type] => text [class] => form-control [id] => marketingtelephone [required] => true [label] => telephone ) [value] => +44 123 456789 ) [marketingemail] => stdclass object ( [attributes] => stdclass object ( [type] => email [class] => form-control [id] => marketingemail [required] => true [placeholder] => you@company.com ) [value] => contact@helloworld.com ) ) [files] => stdclass object ( [marketinglogo] => stdclass object ( [name] => logo1.png [path] => /resources\logo1.png [size] => 2408 [mime] => [attributes] => stdclass object ( [id] => marketinglogo [type] => file [label] => choose file ) ) ) )  

and input boxes:

<perch:input id="marketinglogo" type="file" label="choose file" /> <perch:input type="text" class="form-control" id="marketingtelephone" required="true"  label="telephone" /> <perch:input type="email" class="form-control" id="marketingemail" required="true" placeholder="you@company.com" /> 

my issue is, trying traverse object using:

json_o->marketingid (and various versions) no avail. 

i thought, maybe need go along route of:

foreach ($response $object) {    {     foreach ($object $property=>$value)       {... 

but brutally honest, getting on head not quite understand how need traverse values given in object.

i hope makes sense , apologise lack of knowledge...

it might easier if decode json array rather object. can achieved supplying second argument (true) json_decode as:

$response = json_decode($row['responsejson'], true); 

this should work foreach blocks


Comments

Popular posts from this blog

android - Get AccessToken using signpost OAuth without opening a browser (Two legged Oauth) -

org.mockito.exceptions.misusing.InvalidUseOfMatchersException: mockito -

google shop client API returns 400 bad request error while adding an item -