----- Original Message -----
From: "Bix" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Monday, March 17, 2003 12:04 PM
Subject: [PHP] Looking at individual chars of string


> Is it possible to look at individual chars of a string?
>
> eg: $str = "12345";
>
> print $str_1 // Gives "1"
> print $str_2 // Gives "2"
>
> Doing this with an array would be handy, maybe using explode or
preg_split?
>
> Thanks in advance!

Actually as far as the computer knows strings *are* arrays.  Access any
character within a string in the same mannor as you would access an element
in an array.  For example:

$str = "hello world";
echo $str[4]; // prints o
echo $str[6]; // prints w

HTH,
Kevin



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to