...

View Full Version : Interesting SPLIT problem



jeremywatco
03-19-2004, 02:27 AM
I have a simple problem that is boggling my mind.

Lets say I have a varable like this:


$var1 ='"THIS IS A TEST OF THE EMERGENCY$TESTVAR BRODCAST SYSTEM';

Now I want it to split it right before the $TESTVAR so i get an output of:


$outputvar[0] //should equal "THIS IS A TEST OF THE EMERGENCY"
$outputvar[1] // should equal "$TESTVAR BROADCAST SYSTEM"


However when I do a:


split('$TESTVAR',$var1);

I Get:



$outputvar[0] // equals "THIS IS A TEST OF THE EMERGENCY $TESTVAR"
$outputvar[1] // equals " BROADCAST SYSTEM"


So basically i want to split before my designated expression.

Make any sense? Any ideas?

raf
03-19-2004, 07:52 AM
$var1 ='"THIS IS A TEST OF THE EMERGENCY$TESTVAR BRODCAST
SYSTEM';
$array1=explode('$',$var1);
$array2=array($array1[0], '$'.$array1[1]);


is one of the many way to so this. You could also search for the position and then make two substring.

jeremywatco
03-19-2004, 04:22 PM
Thanks for the help. With a little tweaking I was able to tailor it for my needs and its working perfect. Thank you very much.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum