Why doesn't php support this syntax:
$s = explode('-', 'foo-bar')[0];
?
It's a limitation in the PHP parser. There's no reason why it can't support this form of reduction, it just doesn't.
You can write it using list:
list($first_value) = explode(‘-’,‘foo-bar’);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With