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 TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Getting Array length

Status
Not open for further replies.

sanjdhiman

Programmer
Jan 15, 2003
189
GB
Hi thereone more quick one

I need to try and get the length of an array i.e. number of elements in it so that i can run a for loop and limit the number of loops by the number of elements in the array

any ideas

thanks in advance

sanj
 
if you'd like to count though, just use

count($array);

the foreach statement is great though...

-Rob
 
thanks guys for the advice well test them out

ok i tried the count method.. but that gives me some really dodgy answers

basically if a check box is set i.e. has a value in it (when it is check) it will add that check box item to the array.

no for example i clicked on one check box u would think that if i pass count($region)

it would just have one element but it gives me 6

and if i choose 2 items it gives me 5
and after that i stopped trying

but u know wat that can be?

regards

sanj

 
not a clue without seeing alot more code...

but here's something you can do in your script to help you figure it out.

echo &quot;<pre>&quot;;
print_r($_POST);

or if you're using GET as your form method
print_r($_GET);

Then you can see all sorts of nice information.

-Rob
 
thanks guys u have helped loads

thanks once again

nice one ppl


take care

sanj
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top