I want to print 1,3,5 rows from 2d array. Can I use some kind of implode or loop?
$array = array(
array(11,12,13,14,15,16),
array(21,22,23,24,25,26),
array(31,32,33,34,35,36),
array(41,42,43,44,45,46),
array(51,52,53,54,55,56),
array(61,62,63,64,65,66)
);
I want it to look like this:
"array row 1: 11,12,13,14,15,16"
use this
for($i==;$i<count($array);$i++) {
if($i%2 !=0) {
print_r($array[$i]);
}
}
you can use for
loop. for example :
for($i==;$i<count($array);$i++) {
if($i%2 !=0) {
print_r($array[$i]);
}
}
You can use the following code to print every odd row of an array :
for($i=0;$i<count($array);$i++)
{
if($i%2!=0)
{
print_r($array[$i]);
}
}
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.