Re: Charecter by position
| From: | David Robley | Date: | Thu, 23 Nov 2000 06:00:37 +0000 |
| Subject: | Re: Charecter by position | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-26792@lists.php.net to get a copy of this message | ||
On Thu, 23 Nov 2000, Mike wrote:
> How do I return a charecter by its position in a string
> Example: I want the third charecter from a string
> Thanks
> mpeloso@princeton.edu
A string is an array of characters, so you can get the third character, r
third element of the array with $string[2]
Alternatively you could use the substr function thus:
$char = substr($string, 2);
--
David Robley | WEBMASTER & Mail List Admin
RESEARCH CENTRE FOR INJURY STUDIES | http://www.nisu.flinders.edu.au/
AusEinet | http://auseinet.flinders.edu.au/
Flinders University, ADELAIDE, SOUTH AUSTRALIA