Anshu Pratap Yadav Anshu Pratap Yadav - 1 year ago 106
PHP Question

Convert PHP Array to Json. Using Code-igniter

I Convert PHP Array To JSON Success But My target not full fill.

My out put is:


My Requirement :


Here my code:-

if ($AdminRecord) {

foreach($AdminRecord->result() as $results)
echo json_encode($results);

Answer Source

You are outputting every row, instead try this:

$resultSet = Array();
    foreach($AdminRecord->result() as $result) {
       $resultSet[] = $result;
echo json_encode($resultSet);
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download