How can I check the number of values in an array and echo them in my PHP script?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • olskar
    New Member
    • Apr 2007
    • 1

    #1

    How can I check the number of values in an array and echo them in my PHP script?

    How can I check the number of values in an array and echo them in my PHP script?
  • ranisharda
    New Member
    • Apr 2007
    • 1

    #2
    Originally posted by olskar
    How can I check the number of values in an array and echo them in my PHP script?
    hi
    its so simple!!!!!

    you can use count function to count nuber of elements in array.
    So if your array named $test_array then

    using
    for($num=0;$num <count($test_ar ray);$num++){
    echo $test_array[$num];
    }

    you can echo the elements of array
    :)

    Comment

    • code green
      Recognized Expert Top Contributor
      • Mar 2007
      • 1726

      #3
      [PHP]$num = sizeof($yourArr ay);
      echo 'Number of elements is '.$num;[/PHP]

      Comment

      Working...