Not sure what you want exactly, but here's a way using regexps to retrieve the strings seperatly:
<?php
$string = 'Campus||||||||Bob (Williams)~\\\\\\\\\toms more crap)~\\\\\\\\\blah blah blah)~\\\\\\\\\';
preg_match('#([^|]*)[|]+([^|]*)~[\]+([^\]*)~[\]+([^\]*)~[\]+#Ui', $string, $res);
$campus = $res[1];
$bob = $res[2];
$crap = $res[3];
$blah = $res[4];
?>
Now, if you wanted the positions... then something like this would work:


<?php
$string = 'Campus||||||||Bob (Williams)~\\\\\\\\\toms more crap)~\\\\\\\\\blah blah blah)~\\\\\\\\\';
preg_match('#([^|]*)[|]+([^|]*)~[\]+([^\]*)~[\]+([^\]*)~[\]+#Ui', $string, $res);


$campus = strpos($string, $res[1]);
$bob = strpos($string, $res[2]);
$crap = strpos($string, $res[3]);
$blah = strpos($string, $res[4]);
?>

Dan McCullough wrote:
Hey everyone
Having a bit of trouble with something.
I have a string which has known patterns.
$string"Campus||||||||Bob (Williams)~\\\\\\\\\toms more crap)~\\\\\\\\\blah blah blah)~\\\\\\\\\";
What I am looking for is Location which is Campus
Location Name which is Bob (Williams)
Help?


                
---------------------------------
Do you Yahoo!?
vote.yahoo.com - Register online to vote today!

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



Reply via email to