print partial associative array in php

Geoff

The following lists the whole vector:

foreach($vector as $key=>$value)
{
echo "Key=" . $key . ", Value=" . $value;
echo "<br>";
}

How can I obtain, say, the first ten elements from such an associative array such that all the information of the keys and the values remain intact?

I have tried all sorts of little things I have picked up but I just can't get this to work. I assume I am missing something rather simple!

Nauphal

try this

$count = 0;
foreach($vector as $key=>$value)
{
 echo "Key=" . $key . ", Value=" . $value;
 echo "<br>";
 if(++$count == 10)
 break;
}

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related