Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

arrays 1

Status
Not open for further replies.

bccamp

Technical User
Jan 20, 2005
69
I've got an array:
$array=array("value1"=>$digit1, "value2"=>$digit2);
$arrayvalue=array_values($array)

I'm encoding this into a url and stepping through the array with:
while ($id = count($array,1)) {

I use
$cat = urlencode ($arrayvalues[$id]);
print "<a href=\"$page?id=$cat\">$array[$id]</a>";
$id++; }

I get: Undefined offset: 0
and I don't know what I'm doing wrong. Can someone help?
 
use serialize and unserialize to pass them thru the URL

Bastien

I wish my computer would do what I want it to do,
instead of what I tell it to do...
 
That would be because you don't have a numerical array index of zero in your array. In fact, since your array is purely associative, you don't have any numerical indeces in your array. count(), as you're using it, only returns numbers.

You might want to look into foreach

Want the best answers? Ask the best questions!

TANSTAAFL!!
 
Thanks sleipnir214,

that works great, of course. Just keep it simple.

Barry
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top