的意义是什么 [] [英] What is the meaning of []

查看:49
本文介绍了的意义是什么 []的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个如下代码,但我不确定$ACTIVITYGROUPS[] 有什么类型的数据变量以及如何读取它?

I have a code as below and I am not sure what type of data variable $ACTIVITYGROUPS[] has and how do I read it ?

$ACTIVITYGROUPS[] = saprfc_table_read ($fce, "ACTIVITYGROUPS", $i);

当我做 print_r(saprfc_table_read ($fce, "ACTIVITYGROUPS", $i); 我得到一堆没有任何分隔符的数组,不知道如何提取数据.谁能告诉我什么在上面的句子中是这样吗?

When I did print_r(saprfc_table_read ($fce, "ACTIVITYGROUPS", $i); I got bunch of arrays without any seperator and not sure how to exactract the data. can someone tell me what does it do in above sentences ?

这是 print_r(saprfc_table_read ($fce, "ACTIVITYGROUPS", $i); 结果给我的:

Array (
    [AGR_NAME] => Y:SECURITY_DISPLAY
    [FROM_DAT] => 20080813
    [TO_DAT] => 99991231
    [AGR_TEXT] => Security Display - Users & Roles
    [ORG_FLAG] => C
)

Array (
    [AGR_NAME] => Y:SECURITY_ADMIN_COMMON
    [FROM_DAT] => 20080813
    [TO_DAT] => 99991231
    [AGR_TEXT] => Security Administrator
    [ORG_FLAG] => C
)

Array (
    [AGR_NAME] => Y:LOCAL_TRANSPORT
    [FROM_DAT] => 20090810
    [TO_DAT] => 99991231
    [AGR_TEXT] => Transport into target client - DEV system only
    [ORG_FLAG] =>
)

推荐答案

[] 表示 push - 将给定的参数作为一个新元素放在数组的末尾.这意味着 $ACTIVITYGROUPS 是一个数组*.

[] means push - put the given argument as a new element on the end of the array. That means that $ACTIVITYGROUPS is an array*.

$arr = array();
$arr[] = 1;       // Put 1 in position 0
$arr[] = "a";     // Put "a" in position 1
$arr[] = array()  // Put a new, empty array in position 2

如 PHP 文档所述,array_push 具有与 [] 效果相同.

As stated by the PHP docs, array_push has the same effect as [].

* 如果不是数组,使用 [] 会给你一个语法错误:

* If it's not an array, using [] will give you a syntax error:

警告:不能在第 4 行的 test.php 中使用标量值作为数组

Warning: Cannot use a scalar value as an array in test.php on line 4

这篇关于的意义是什么 []的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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