Forum Moderators: coopster
If I have a string such as....
$a = "Start Middle End";
How can I extract "Middle" out of this and put it into $b? I want to do it by searching for the first space and stripping it out of $a. Then I will be left with "Middle End". Then I want to search for the first space and strip it and anything after that and be left with "Middle".
Does anyone know how to easily do this? Can you show me an example of this?
Thanks
Dean
EX.
$a = "123456@9999$654321";
How can I find "@" in this string and strip it and everything before to be left with this. "9999$654321"? Then I would have something like this I am thinking...
$b = "9999$654321";
Now I want to search this string for "$" and strip it and everything after it to be left with "9999".
Thanks
Dean
$a = "123456@9999$654321";
$b = substr($a, strpos($a, '@') + 1);
print $b; // prints 9999$654321
$c = substr($b, 0, strpos($b, '$'));
print $c; // prints 9999
$a = "123456@9999$654321";
preg_match [php.net]('/\@([^\$]+)\$/', $a, $matches);
print $matches[1];