Error in Php Array

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • kkshansid
    New Member
    • Oct 2008
    • 232

    Error in Php Array

    plz help as my code is not running. its not printing array

    [PHP]<?php
    $i=1;
    $j=0;
    $pidarray=array ();
    while($i<10)
    {
    $pidarray[$j]=$i;
    $i++;
    $j++;
    }
    print_r($pidarr ay[$j]);
    ?>[/PHP]
    i think its correct formate
    as i received 3 warnings
    Last edited by kkshansid; Oct 24 '08, 05:47 AM. Reason: i dont want to b banned
  • chelvan
    New Member
    • Aug 2008
    • 90

    #2
    hi
    do u wish to print the numbers from 1 - 9. if so move your print statement in to your loop.

    hope that will work.

    regards
    chel-1

    Comment

    • kkshansid
      New Member
      • Oct 2008
      • 232

      #3
      Originally posted by chelvan
      hi
      do u wish to print the numbers from 1 - 9. if so move your print statement in to your loop.

      hope that will work.

      regards
      chel-1
      no its not working niether inside loop nor outside
      print_r prints whole array
      it should work outside loop also.it should print no from 1-9 with array index

      Comment

      • kkshansid
        New Member
        • Oct 2008
        • 232

        #4
        Originally posted by kkshansid
        plz help as my code is not running. its not printing array

        [PHP]<?php
        $i=1;
        $j=0;
        $pidarray=array ();
        while($i<10)
        {
        $pidarray[$j]=$i;
        $i++;
        $j++;
        }
        print_r($pidarr ay[$j]);
        ?>[/PHP]
        i think its correct formate
        as i received 3 warnings
        answered by myself it should be
        print_r($pidarr ay)

        Comment

        • chelvan
          New Member
          • Aug 2008
          • 90

          #5
          hi
          just change your print statement like this, on out of the loop

          Code:
          print_r($pidarray);
          hope this time it will work

          chel-1

          Comment

          • ak1dnar
            Recognized Expert Top Contributor
            • Jan 2007
            • 1584

            #6
            Thread title changed from "error" to "Error in Php Array".

            Please Use a Good Thread Title
            Using a good, clear thread title is important. The reasons for this are

            Comment

            Working...