views:

30

answers:

2

hey okay so lets say $word = [email protected]

can i make a new variable only everything upto the "@"

and another everything after?

( I.E. $one = abcdefg & $two = hijk.lmn )

thanks alot

+5  A: 

use explode.

$word = '[email protected]';
$my_array = explode('@', $word);
echo $my_array[0]; // prints "abcdefg"
echo $my_array[1]; // prints "hijk.lmn"

http://php.net/manual/en/function.explode.php

no
And if you want to assign the parts to variables rather than an array, use `list($one, $two) = explode('@', $word);`
Ben Blank
I think i love you guys. Thanks a lot!
Matthew Carter
A: 
list($one, $two) = split("@", $word);
Vikash
`split` is deprecated as of 5.3. It's also overkill (uses a regex where one is not needed).
no
Thanks! I never noticed.
Vikash