如何使用 CodeIgniter 遍历并显示以下 JSON 中的名称?
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
class Search extends CI_Controller {
public function index()
{
$json = '[{"name": "John Doe",
"address": "115 Dell Avenue, Somewhere",
"tel": "999-3000",
"occupation" : "Clerk"},
{"name": "Jane Doe",
"address": "19 Some Road, Somecity",
"tel": "332-3449",
"occupation": "Student"}]';
for (int $i = 0; $i < $json.length; $i++){
???
}
//$obj = json_decode($json);
//$this->load->view('search_page');
}
}
/* End of file search.php */
/* Location: ./application/controllers/search.php */