Page 1 of 1
Arrays.
Posted: Fri Jun 09, 2006 5:34 pm
by JellyFish
I need to learn more about arrays. If there is a site you know of that explains everything about php arrays, send it to me.
My basic question is, Can an array look like?: $array[1][4]
Any other help on this subject is appreciated.
Thanks for reading.
Re: Arrays.
Posted: Fri Jun 09, 2006 5:40 pm
by ambivalent
EasyGoing wrote:
My basic question is, Can an array look like?: $array[1][4]
Yes
php.net - arrays
Ch 5 - Arrays
HTH
Posted: Fri Jun 09, 2006 10:57 pm
by JellyFish
I've been looking around and for some reason I can't find how to get the length of an array?
How do you get the length of an array? In other words, how do you return the length of an array?
Posted: Fri Jun 09, 2006 11:35 pm
by ambivalent
EasyGoing wrote:I've been looking around and for some reason I can't find how to get the length of an array?
Read
Ch 5.1again, it contains valuable information with respect to the
count() function.
Posted: Sat Jun 10, 2006 1:53 am
by JellyFish
So count($myarray) would return my arrays length. All right, thanks.

Posted: Sat Jun 10, 2006 7:47 am
by Li0rE
if you mean the length of all the characters in the array, you can just to this
Code: Select all
<?php
$length = implode(" ", $array);
$length = strlen($length);
echo("This array contains $length characters.");
?>
Posted: Sat Jun 10, 2006 2:24 pm
by JellyFish
No I just meant the length meaning how many values it has. But thanks for the post, it's good stuff.
How does the count function works? Does it start at 0 like the arrays index does? Or is the first value in the array 1?
For example if I put:
$length = count($myarray);
and my array has:
so, and, what, not
would the first value (so) be 0 in $length or would it be 1?