-4

文字列入力の例:

$var = "9999-111 Google";
$var_2 = "9999-222 StackOverflow Web";

I want to get only the postcode and then the address.

$postcode_A = explode(" ", $var);
// postcode[0] returns '9999-111' - postcode[1] returns 'Google'

$postcode_B = explode(" ", $var_2);
// postcode[0] returns '9999-222' - postcode[1] returns 'StackOverflow'
// and I want postcode[1] to return 'StackOverflow Web';

どうすればそれを達成できますか?ありがとう。

4

2 に答える 2

4

爆発limitのオプションを使用する

list($post_code, $name)  = explode(" ", $var_2, 2);
于 2013-11-12T12:15:24.620 に答える