Page 1 of 1

preg_split

Posted: Mon Nov 28, 2005 6:36 pm
by spacebiscuit
Am I misunderstanding the preg_split function?

I want to extract the letter B from "ABCDEF":

Code: Select all

$keywords = preg_split("/A+C/", "ABCDEF");
print_r($keywords);
However I am getting :

Code: Select all

Array ( [0] => ABCDEF )
I have no idea how this can be?

Any ideas?

Thanks,

Rob.

Posted: Mon Nov 28, 2005 7:01 pm
by Chris Corbyn
preg_split() is regex. You might want to read the tutorials stickied in the Regex forum here.

If you're looking to extract part of a string you're most likely going to want preg_match() but if it's just a single character you may aswell not use regex at all :D