By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
438,278 Members | 1,357 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 438,278 IT Pros & Developers. It's quick & easy.

Error in Php Array

100+
P: 232
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($pidarray[$j]);
?>[/PHP]
i think its correct formate
as i received 3 warnings
Oct 24 '08 #1
Share this Question
Share on Google+
5 Replies


chelvan
P: 90
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
Oct 24 '08 #2

100+
P: 232
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
Oct 24 '08 #3

100+
P: 232
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($pidarray[$j]);
?>[/PHP]
i think its correct formate
as i received 3 warnings
answered by myself it should be
print_r($pidarray)
Oct 24 '08 #4

chelvan
P: 90
hi
just change your print statement like this, on out of the loop

Expand|Select|Wrap|Line Numbers
  1. print_r($pidarray);
  2.  
hope this time it will work

chel-1
Oct 24 '08 #5

ak1dnar
Expert 100+
P: 1,584
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
Oct 24 '08 #6

Post your reply

Sign in to post your reply or Sign up for a free account.