I am new to codeigniter.
when need to display 5th element value of an array in java normally we use,
System.out.print(array[4]);
in controller of codeigniter I use,
$data['test'] = $this->Model_test->getValues();
to assign value into the array. and then I use,
$this->load->view('test_view', $data);
to load view.
inside view I use,
foreach ($questions as $object) {
echo $object->question;
}
to display all values. If I need to display only the value of 5th element, what should I do?
尝试这个
print_r($questions[4]); # This will print fifth element of an array
Try this,
foreach ($questions as $object) {
echo $object->question;
}
Above will echo each row's question. to get only 5th row, check this.
echo $questions[5]->question;
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.