1

The answer is probably obvious for many of you, but : how can I make the function "count" work proprerly ? Here four lines of my program :

$liste=array($serie); 
if (is_array($liste))  {
    echo "Dans la proc., Liste est toujours un tableau<br>";
} 
echo "Nb de lignes de la liste : " . count($liste)."<br>";

The answer to my if is true, but count is 1 - actually 1163 elements !

1
  • 2
    If $serie is already an array then just do $liste = $serie; Commented May 20, 2016 at 7:51

1 Answer 1

1

$liste=array($serie); this code creating an new array that's why its count is 1. assign it directly as below

$liste = $serie; 
if (is_array($liste))  {
    echo "Dans la proc., Liste est toujours un tableau<br>";
} 
echo "Nb de lignes de la liste : " . count($liste)."<br>";

I recommend to echo your count() inside the if statement.

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.