Facing problem with count

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
soul_fly
Forum Newbie
Posts: 22
Joined: Mon Aug 24, 2009 2:24 pm

Facing problem with count

Post by soul_fly »

Hello there.

The problem:
$matches got 10 results. After I do print_r($mathces); I get this: Array ( [0] => Array ( [0] => hello [1] => hi [2] => devnet [3] => soul [4] => fly ........

Target: I was also trying to echo total number of results, like " You have 10 results in matches"

I tried echo "You Have ".count($matches)."results..";

Actually I'm facing problem with the count of results i have from output. Thanks for your co-operation in advance.

:)
User avatar
John Cartwright
Site Admin
Posts: 11470
Joined: Tue Dec 23, 2003 2:10 am
Location: Toronto
Contact:

Re: Facing problem with count

Post by John Cartwright »

You were not clear what the issue is.

Are you saying you want to count the first element's array, instead of the original array?

i.e.

Code: Select all

echo "You have ". count($matches[0]) ." results";
soul_fly
Forum Newbie
Posts: 22
Joined: Mon Aug 24, 2009 2:24 pm

Re: Facing problem with count

Post by soul_fly »

John Cartwright wrote:You were not clear what the issue is.

Are you saying you want to count the first element's array, instead of the original array?

i.e.

Code: Select all

echo "You have ". count($matches[0]) ." results";
Yes exactly. Thank you very much. :)
Post Reply