如何在同一行中使用爆炸()时访问数组索引? [英] How to access array index when using explode() in the same line?
问题描述
不能环绕此我的头...
Can't wrap my head around this...
说,我们爆炸整个事情像这样:
Say, we explode the whole thing like so:
$ =提取爆炸('TRA-LA-LA,$ big_sourse);
$extract = explode('tra-la-la', $big_sourse);
然后我们要在索引1得到一个值:
Then we want to get a value at index 1:
$光洁度= $提取物[1];
$finish = $extract[1];
我的问题是如何得到它一气呵成,说话等等。类似这样的内容:
My question is how to get it in one go, to speak so. Something similar to this:
$完成=爆炸(TRA-LA-LA,$ big_sourse)[1]; //不能正常工作
$finish = explode('tra-la-la', $big_sourse)[1]; // does not work
像下面的内容将工作就像一个魅力:
Something like the following would work like a charm:
$ =完成结束(爆炸(TRA-LA-LA,$ big_sourse));
$finish = end(explode('tra-la-la', $big_sourse));
//或
$完成= array_shift(爆炸(TRA-LA-LA,$ big_sourse));
$finish = array_shift(explode('tra-la-la', $big_sourse));
但是,如果该值的某处坐在中间是什么?
But what if the value is sitting somewhere in the middle?
推荐答案
函数数组取消引用有在PHP 5.4中实现。对于老版本的在PHP解析器的限制,即固定在这里 ,所以没有办法解决它,现在我害怕。
Function Array Dereferencing has been implemented in PHP 5.4. For older version that's a limitation in the PHP parser that was fixed in here, so no way around it for now I'm afraid.
这篇关于如何在同一行中使用爆炸()时访问数组索引?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!