note 8611 modified in Arrays by jmcastagnetto
| From: | jmcastagnetto@php.net | Date: | Sat, 23 Sep 2000 12:28:50 +0000 |
| Subject: | note 8611 modified in Arrays by jmcastagnetto | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-5440@lists.php.net to get a copy of this message | ||
[Editor's note: Slicing is akin to retrieving rows from a matrix, not columns from it. If you
need matrix code look for example at www.sourceforge.net/numphp]
It appears that multi-dimesional arrays cannot be sliced vertically.
The following code does not work:
$test_array = array(0=>array('bar'=>'a',
'baf'=>'aa','baz'=>'aaa'),
1=>array('bar'=>'b',
'baf'=>'bb','baz'=>'bbb'),
2=>array('bar'=>'c',
'baf'=>'cc','baz'=>'ccc'));
$test_slice = $test_array['bar'];
echo "<h1>$test_slice</h1>\n";
for (reset($test_slice);$v=current($test_slice);next($test_slice)){
echo "{$v[0]}<br>\n<br>\n";
}
http://www.php.net/manual/arrays.php