0

I want to get the count for the second index in an array, and have searched for quite a while, but still haven't found an answer, and still have no idea how. Please take a look:

$array[0][0] = 1;
$array[0][1] = 2;
$array[0][2] = 3;

$arrayCount = count($array);
echo $arrayCount;

output would be:

1

However, I actually want the count of the second index. If I am able to get it, the output would be:

3

Is there any way to get the count of the second index? Please let me know. Thank you.

1
  • try $arrayCount = count($array[0]); Commented May 29, 2015 at 2:33

1 Answer 1

1

You are trying to count $array which is one.

If you are looking for counting array index, use

$arrayCount = count($array[0]);

Hope it helps.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.