Click to See Complete Forum and Search --> : PHP, Isolating characters


Cerf
08-03-2003, 11:20 PM
Yo yo yo,

I'm writing a script in php that reads a very larg file containing alot of information. The problem is that if the information is entered in wrong, errors are generated.

To combat this problem, in a temporary measure, I kneed to know how to isolat characters

Put easily, how can I figure what the first character of a string is.

e.g.
if the first character in a string == 'a' then ...
if the fist character in a string == '#' then...
else ...

sporko
08-03-2003, 11:40 PM
Hmm.. from what I understand it seems like Perl would be the best way to do this but if you could please explain more it would help.

Cerf
08-04-2003, 01:10 PM
so lets say I had a string

$mystring = "The quick brown fox jumped over the lazy dog";

what I want will return "T" because it is the first character in the string

goon12
08-04-2003, 02:16 PM
Wouldnt $mystring[0] ( Thats a zero ) be "T"?

-goon12

Cerf
08-04-2003, 05:07 PM
Whow that was so simple

Thanks