我能分开一个php变量吗?

Don*_*uma 1 html php string variables

好吧,让我们说$ word = abcdefg@hijk.lmn

我可以创建一个新的变量只有"@"的一切

和之后的一切?

(IE $ 1 = abcdefg&$ two = hijk.lmn)

非常感谢

Dag*_*bit 5

explode.

$word = 'abcdefg@hijk.lmn';
$my_array = explode('@', $word);
echo $my_array[0]; // prints "abcdefg"
echo $my_array[1]; // prints "hijk.lmn"
Run Code Online (Sandbox Code Playgroud)

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

  • 如果你想将部分分配给变量而不是数组,请使用`list($ one,$ two)= explode('@',$ word);` (3认同)