Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
次のコードを 1 行で記述できますか?
$foo = explode(":", $foo); $foo = $foo[0];
これにはstristrを使用できます。
$foo = stristr($foo,":",true);
true を設定すると、「:」の最初のインスタンスの前にすべてが表示されます。
list() の代わりに、array_shift()を使用できます。
$foo = array_shift(explode(':', $foo));
はい、次を使用して実行できますlist。
list
list($foo) = explode(":", $foo);