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

ermm Arrays are broken?

P: n/a
NK
Hi all,

Okay its about 2:30am here so maybe I'm REALLY missing something here
but, well this code returns a blank page!

$a[] = 'HELLO PHP, WHATS WRONG?';
print($a[0]);

any ideas why this could be happening??

Thanks!
NK
Jul 17 '05 #1
Share this Question
Share on Google+
6 Replies


P: n/a
NK wrote:
Hi all,

Okay its about 2:30am here so maybe I'm REALLY missing something here
but, well this code returns a blank page!

$a[] = 'HELLO PHP, WHATS WRONG?';
print($a[0]);

any ideas why this could be happening??


Maybe you're reusing the array?

<?php
$a[] = 'zero';
unset($a[0]); // should be unset($a);
$a[] = 'one';
print($a[0]);
?>
--
--= my mail box only accepts =--
--= Content-Type: text/plain =--
--= Size below 10001 bytes =--
Jul 17 '05 #2

P: n/a
NK
Hrrrrm, nope, that was actually all that was in the file.,.. I was
trying to demonstrate an Array to a friend and that was the problem...
....except for <?php ?> , you saw the complete script :/
Pedro Graca wrote:
NK wrote:
Hi all,

Okay its about 2:30am here so maybe I'm REALLY missing something here
but, well this code returns a blank page!

$a[] = 'HELLO PHP, WHATS WRONG?';
print($a[0]);

any ideas why this could be happening??

Maybe you're reusing the array?

<?php
$a[] = 'zero';
unset($a[0]); // should be unset($a);
$a[] = 'one';
print($a[0]);
?>

Jul 17 '05 #3

P: n/a
[ please do not top-post ]

NK top-posted:
Pedro Graca wrote:
NK wrote:
..., well this code returns a blank page!

$a[] = 'HELLO PHP, WHATS WRONG?';
print($a[0]);
Maybe you're reusing the array?
Hrrrrm, nope, that was actually all that was in the file.,.. I was
trying to demonstrate an Array to a friend and that was the problem...
...except for <?php ?> , you saw the complete script :/


I think I saw something about arrays starting at 1 somewhere ... but
can't find it now. What version of PHP are you using?
--
--= my mail box only accepts =--
--= Content-Type: text/plain =--
--= Size below 10001 bytes =--
Jul 17 '05 #4

P: n/a
NK wrote:

Okay its about 2:30am here so maybe I'm REALLY missing something here
but, well this code returns a blank page!

$a[] = 'HELLO PHP, WHATS WRONG?';
print($a[0]);

any ideas why this could be happening??


Try :

<?PHP
error_reporting(E_ALL);
$a[] = 'HELLO PHP, WHATS WRONG?';
print_r($a);
?>

It should show the text in there and what key it's at.
You're sure you didn't type WHAT'S WRONG instead of WHATS WRONG?

Regards,
Shawn
--
Shawn Wilson
sh***@glassgiant.com
http://www.glassgiant.com
Jul 17 '05 #5

P: n/a
I wrote:
I think I saw something about arrays starting at 1 somewhere ... but
can't find it now. What version of PHP are you using?


Oops, sorry all
.... maybe that was a Perl issue :)
--
--= my mail box only accepts =--
--= Content-Type: text/plain =--
--= Size below 10001 bytes =--
Jul 17 '05 #6

P: n/a
NK
It working now :/ Perhaps there was a caching issue on my browsers
(Safari, IE and Camino)??? Hrmmm anyways thanks heaps for your help guys :)
Pedro Graca wrote:
I wrote:
I think I saw something about arrays starting at 1 somewhere ... but
can't find it now. What version of PHP are you using?

Oops, sorry all
... maybe that was a Perl issue :)

Jul 17 '05 #7

This discussion thread is closed

Replies have been disabled for this discussion.