how to split cut trim a value into 2 new vars?

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
ianhull
Forum Contributor
Posts: 310
Joined: Tue Jun 14, 2005 10:04 am
Location: Hull England UK

how to split cut trim a value into 2 new vars?

Post by ianhull »

hi guys,

I need to trim split slice cut or whatever it is to get this into two variables.

Code: Select all


$value1___$value2

I placed the three undescores there so that I could somehow modify it but I can't work it out.

Please help.

Thanks
afbase
Forum Contributor
Posts: 113
Joined: Tue Aug 15, 2006 1:29 pm
Location: SoCAL!!!!

Post by afbase »

Code: Select all

$value1."____".$value2;
i'm not sure what you are looking for. Please elaborate, if the value(s) are strings try substr()
User avatar
superdezign
DevNet Master
Posts: 4135
Joined: Sat Jan 20, 2007 11:06 pm

Post by superdezign »

Lol. Underscores aren't magical.
If you already have the variables, why would you need to add underscores....?


I'm pretty sure you're after this:

Code: Select all

$str = "Blah___Blah some more";
$strArray = split('___', $str);
$value1 = $strArray[0];
$value2 = $strArray[1];
If not... Then we're totally lost.
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

Don't use split(), use explode() or, if necessary preg_split(), but never split().
Post Reply