php_begins Posted February 6, 2012 Share Posted February 6, 2012 I am returning the following through JSON: $this->view->lead_query=$lead_query->fetchALL(); header('OK', true, 200); header('Content-type: application/json'); echo json_encode($this->view->lead_query); I am getting the results in this format: [{"client_name":"Steve Harris","state":"TX"}] Now if the above output was displayed without the square brackets [] I can populate the values in my form correctly. Is there a way i can return the output without the square brackets? Link to comment https://forums.phpfreaks.com/topic/256502-return-json-output-without-square-brakets/ Share on other sites More sharing options...
digibucc Posted February 6, 2012 Share Posted February 6, 2012 <?php echo str_replace( array( '[', ']'), '', json_encode($this->view->lead_query)); ?> would be the best way i think. Link to comment https://forums.phpfreaks.com/topic/256502-return-json-output-without-square-brakets/#findComment-1314908 Share on other sites More sharing options...
php_begins Posted February 6, 2012 Author Share Posted February 6, 2012 That works great..thanks!! Link to comment https://forums.phpfreaks.com/topic/256502-return-json-output-without-square-brakets/#findComment-1314916 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.