Connecting Tech Pros Worldwide Help | Site Map

ermm Arrays are broken?

 
LinkBack Thread Tools Search this Thread
  #1  
Old July 17th, 2005, 01:35 AM
NK
Guest
 
Posts: n/a
Default ermm Arrays are broken?

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

  #2  
Old July 17th, 2005, 01:35 AM
Pedro Graca
Guest
 
Posts: n/a
Default Re: ermm Arrays are broken?

NK wrote:[color=blue]
> 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??[/color]

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 =--
  #3  
Old July 17th, 2005, 01:35 AM
NK
Guest
 
Posts: n/a
Default Re: ermm Arrays are broken?

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:
[color=blue]
> NK wrote:
>[color=green]
>>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??[/color]
>
>
> Maybe you're reusing the array?
>
> <?php
> $a[] = 'zero';
> unset($a[0]); // should be unset($a);
> $a[] = 'one';
> print($a[0]);
> ?>[/color]
  #4  
Old July 17th, 2005, 01:35 AM
Pedro Graca
Guest
 
Posts: n/a
Default Re: ermm Arrays are broken?

[ please do not top-post ]

NK top-posted:[color=blue]
> Pedro Graca wrote:[color=green]
>> NK wrote:[color=darkred]
>>>..., well this code returns a blank page!
>>>
>>>$a[] = 'HELLO PHP, WHATS WRONG?';
>>>print($a[0]);[/color][/color][/color]
[color=blue][color=green]
>> Maybe you're reusing the array?[/color][/color]
[color=blue]
> 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 :/[/color]

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 =--
  #5  
Old July 17th, 2005, 01:35 AM
Shawn Wilson
Guest
 
Posts: n/a
Default Re: ermm Arrays are broken?

NK wrote:[color=blue]
>
> 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??[/color]

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
shawn@glassgiant.com
http://www.glassgiant.com
  #6  
Old July 17th, 2005, 01:36 AM
Pedro Graca
Guest
 
Posts: n/a
Default Re: ermm Arrays are broken?

I wrote:[color=blue]
> I think I saw something about arrays starting at 1 somewhere ... but
> can't find it now. What version of PHP are you using?[/color]

Oops, sorry all
.... maybe that was a Perl issue :)
--
--= my mail box only accepts =--
--= Content-Type: text/plain =--
--= Size below 10001 bytes =--
  #7  
Old July 17th, 2005, 01:36 AM
NK
Guest
 
Posts: n/a
Default Re: ermm Arrays are broken?

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:
[color=blue]
> I wrote:
>[color=green]
>>I think I saw something about arrays starting at 1 somewhere ... but
>>can't find it now. What version of PHP are you using?[/color]
>
>
> Oops, sorry all
> ... maybe that was a Perl issue :)[/color]
 

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Popular Articles

What is Bytes?

We are a network of experts and professionals in IT and software development that help one another with answers to tough questions and share insights. Get the best answers to your questions from over 220,989 network members.