php - 奇怪的数组语法

标签 php syntax arrays

我正在尝试弄清楚为我提供的功能是如何工作的——或者更确切地说,它是如何工作的。有问题的区域包括像这样的数组符号:

$small[$end[$i]{0}]

认为这个想法是将“0”附加到$end[$i] 的值,并将其用于$small 的索引。但它在 PHP5.3 中不起作用。这是一种已弃用的语法吗?它是否在尝试按照我的想法行事?

最佳答案

它从 $end[$i] 字符串中获取第一个字符,然后使用该字符作为数组键访问 $small 数组。

编辑:

Since $foo=200; $foo[0] != 2;//=='', what do you recommend for getting the leftmost digit when the magnitude of the number is unknown?

最简单的方法是在 PHP 中使用 substr($foo, 0, 1)

如果您使用的是强类型语言,我有一些指标您可能有兴趣阅读我的另一个答案:How can you get the first digit in an int (C#)?

关于php - 奇怪的数组语法,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2699098/

相关文章:

java - 如何将这些分数相加得出最终值?

arrays - 为什么 JSON 返回这样的值 2.2348142859517371e-314 和 6.9531204333502763e-310

cPanel 中的 PHP Cron 作业无法正常工作

PHPExcel公式边框粗细问题

ruby - 使用<<时出现语法错误,但使用+ =时则没有

python - print(... sep ='' , '\t' ) 是什么意思?

php - INSERT 请求在没有错误消息的情况下不起作用

php - 如何用php根据数据库中的值绘制水平直方图?

javascript - jQuery 对 Javascript 函数的请求

javascript数组取消移位一些元素