473,396 Members | 1,712 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

ermm Arrays are broken?

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
6 1640
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
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
[ 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
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
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
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

12
by: Duderonomoy | last post by:
Hello, I am querying the JavaScript community to learn if others are having problems with Safari and JavaScript arrays: myImages = ; then referenced like this:
79
by: Me | last post by:
Just a question/observation out of frustration. I read in depth the book by Peter Van Der Linden entitled "Expert C Programming" (Deep C Secrets). In particular the chapters entitled: 4: The...
23
by: yatindran | last post by:
hai this is my 2d array. int a = { {5,2,20,1,30,10}, {23,15,7,9,11,3}, {40,50,34,24,14,4}, {9,10,11,12,13,14}, {31,4,18,8,27,17}, {44,32,13,19,41,19}, {1,2,3,4,5,6},
17
by: Paminu | last post by:
Is there no such a thing as an ArrayOutOfBounds exception in C? I just did: int main() { int a; // a is an array that contains 4 integer. a = 999; // Thought this would give an error!...
2
by: Andrew Burlak | last post by:
Hi, Although Unsized Arrays inside structures is a non-standard feature, I like to use it :-) It seems that Unsized Arrays are broken when /Og (Global Optimization) is enabled. The problem...
10
by: madhura | last post by:
Hello, I have a problem with 2-d arrays and scanf function. I have wriitten a code in which i am accepting values in 1-d arrays int a,i; for(i=0;i<3;i++) scanf("%d",a+i); when I print the...
20
by: drM | last post by:
Could anyone please offer some advice: Trying to play with character arrays in C, the code below generates this error. Anyone see something wrong? thank you in advance. >>>>>>>> #include...
14
by: rohitpatel9999 | last post by:
Hi While developing any software, developer need to think about it's possible enhancement for international usage and considering UNICODE. I have read many nice articles/items in advanced C++...
16
by: mike3 | last post by:
(I'm xposting this to both comp.lang.c++ and comp.os.ms- windows.programmer.win32 since there's Windows material in here as well as questions related to standard C++. Not sure how that'd go over...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.