I have a table in a mySQL database titled 'xs' which holds a column titled 'result', which holds an array of xml values. I have converted this to json using:
public function getResults(){ $xml_clean = stripslashes(trim($xs->result)); $xml = simplexml_load_string($xml_clean); if(isset($xml->Consumer)){ $result['consumer_name'] = json_encode($xml->Consumer->ConsumerName); $result['consumer_contact_no'] = json_encode($xml->Consumer->ConsumerTelephoneNo); } return $result; } The $xml_clean variable was my attempt at removing special characters but it actually provides no use, the output is the same as without it.
My output from the php view is:
Name: {"0":"Jason Statham"} Contact Number: {"0":"'071 555 9875"} How may I format the above to look like this:
Name: Jason Statham
Contact Number: 071 555 9875
No comments:
Post a Comment