- json_encode: documentation ( source)
<?php
$array = array(
array(
'1' => '2',
'2' => '3'
),
array(
'1' => '3',
'2' => '2',
'3' => '2'
)
);
$arr = array();
foreach ($array as $row) {
$arr[] = $row;
}
echo json_encode($arr);