preventing an array from being treated like a string - Programmers Heaven

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

preventing an array from being treated like a string

lih0nmanlih0nman Posts: 30Member
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.

Comments

  • mac_doggiemac_doggie Posts: 488Member
    : 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.
    :
    [code]
    if(is_array($time)) {
    echo $time[1];
    }else {
    echo "Error...";
    }
    [/code]
    ;-)
    -mac-
    mailto:[email protected]
    the Netherlands...


Sign In or Register to comment.