PHP

Moderators: None (Apply to moderate this forum)
Number of threads: 1848
Number of posts: 5016

This Forum Only
Post New Thread
Single Post View       Linear View       Threaded View      f

Report
preventing an array from being treated like a string Posted by lih0nman on 30 Sept 2006 at 8:42 AM
i know that retrieving a particular character from a string and retrieving a particular record from an array has the same syntax in PHP. when i build an array like this -

$n = 1;
while ($n != 10) {
$time[$n] = time * $n;
$n += 1;
}
echo $time[1];

how can i ensure that i am retrieving the first record from the array $time, not the second character from $time[1]?

thanks.
Report
Re: preventing an array from being treated like a string Posted by mac_doggie on 6 Oct 2006 at 2:27 PM
: i know that retrieving a particular character from a string and retrieving a particular record from an array has the same syntax in PHP. when i build an array like this -
:
: $n = 1;
: while ($n != 10) {
: $time[$n] = time * $n;
: $n += 1;
: }
: echo $time[1];
:
: how can i ensure that i am retrieving the first record from the array $time, not the second character from $time[1]?
:
: thanks.
:
if(is_array($time)) {
  echo $time[1];
}else {
  echo "Error...";
}


-mac-
mailto:mac_doggie@hotmail.com
the Netherlands...





 

Recent Jobs

Official Programmer's Heaven Blogs
Web Hosting | Browser and Social Games | Gadgets

Popular resources on Programmersheaven.com
Assembly | Basic | C | C# | C++ | Delphi | Flash | Java | JavaScript | Pascal | Perl | PHP | Python | Ruby | Visual Basic
© Copyright 2011 Programmersheaven.com - All rights reserved.
Reproduction in whole or in part, in any form or medium without express written permission is prohibited.
Violators of this policy may be subject to legal action. Please read our Terms Of Use and Privacy Statement for more information.
Operated by CommunityHeaven, a BootstrapLabs company.