0
$datas = array();

while($row = mysql_fetch_array($firstQueryResult)) {
    $phones["Id"] = $row['person_id'];
    $phones["Latitude"] = $row['lat'];
    $phones["Longitude"] = $row['lng'];
    $phones["Distance"] = $row['distance'];
    $phones["DateTime"] = $row['location_datetime'];
    $datas["mydata"][] = $phones;
}

echo "Count = ".count($datas); // always returning 1 while i have more than 1 recor
echo "Count = ".sizeof($datas); // always returning 1 while i have more than 1 record

Anyone can please help me.

2
  • 1
    What about echo "Count = ".count($datas['mydata']); Commented Sep 26, 2014 at 6:32
  • If the parameter is not an array or not an object with implemented Countable interface, 1 will be returned. Commented Sep 26, 2014 at 6:32

2 Answers 2

4

Try this

echo "Count = ".count($datas['mydata']);
echo "Count = ".sizeof($datas['mydata']);
Sign up to request clarification or add additional context in comments.

Comments

0

$datas has only 1 element -> "mydata".

You want to count the number of entries in mydata, so :

count($datas["mydata"]);

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.