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? Quote 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. Quote 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!! Quote 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
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.