定义数组索引后函数调用 [英] Define array index after function call

查看:98
本文介绍了定义数组索引后函数调用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在其他语言如C#和JavaScript,我能够访问与函数调用数组的索引,如

In other languages such as C# and JavaScript, I am able to access the index of an array with a function call such as

getMyArray()[0] 

这将使我访问结果的第一个指标,而不是回传整个数组,然后设置的结果。

This would allow me to access the first index of the result instead of passing back the entire array and then setting the result.

不过这个快捷方式无法用PHP工作。有没有办法让这个快捷方式?

However this shortcut does not work with PHP. Is there a way to get this shortcut?

推荐答案

您需要才能使用<运行PHP 5.4 href=\"http://razvantudorica.word$p$pss.com/2011/07/14/array-dereferencing-support-in-php-5-4-0/\">array取消引用。

这篇关于定义数组索引后函数调用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆