PHP代码 - 这部分代码是什么意思?

时间:2022-09-06 14:30:28

what does the assignment in this loop do? I don't get the array notation in it :S

这个循环中的赋值是做什么的?我没有得到它的数组符号:S

foreach($fieldvalues as $fieldvalue){
    $insertvalues[] = $fieldvalue;
 }

5 个解决方案

#1


3  

$insertvalues[] means insert a new item into the array, its a shortcut of array_push(). Its also preferred as it created lesser overhead whilst the PHP is working.

$ insertvalues []表示在数组中插入一个新项,它是array_push()的快捷方式。它也是首选,因为它在PHP工作时创建了较少的开销。

Additional:

For those who are unsure how the loop works.

对于那些不确定循环如何工作的人。

foreach($fieldvalues as $fieldvalue)

every time the loop... loops, the value $fieldvalue becomes the next value a pointer is looking it in the array $fieldvalues - thus adding this to a new array `$insertvalues by means of the shortcut syntax mentioned above.

每次循环...循环时,值$ fieldvalue成为指针在数组$ fieldvalues中查找它的下一个值 - 因此通过上面提到的快捷语法将它添加到新数组`$ insertvalues中。

#2


5  

Add $fieldvalue to the end of the $insertvalues array.

将$ fieldvalue添加到$ insertvalues数组的末尾。

#3


1  

It inserts a new item at the end of the array.

它在数组的末尾插入一个新项。

Other languages tend to have an append or push function for this.

其他语言往往具有附加或推送功能。

#4


0  

It adds the value of $fieldvalue at the end of $insertvalues array. The [] creates an array and values of the specified variable are added to it at the end each time.

它在$ insertvalues数组的末尾添加了$ fieldvalue的值。 []创建一个数组,每次在末尾添加指定变量的值。

#5


0  

I think, This is variable for New Array.

我想,这对New Array来说是可变的。

#1


3  

$insertvalues[] means insert a new item into the array, its a shortcut of array_push(). Its also preferred as it created lesser overhead whilst the PHP is working.

$ insertvalues []表示在数组中插入一个新项,它是array_push()的快捷方式。它也是首选,因为它在PHP工作时创建了较少的开销。

Additional:

For those who are unsure how the loop works.

对于那些不确定循环如何工作的人。

foreach($fieldvalues as $fieldvalue)

every time the loop... loops, the value $fieldvalue becomes the next value a pointer is looking it in the array $fieldvalues - thus adding this to a new array `$insertvalues by means of the shortcut syntax mentioned above.

每次循环...循环时,值$ fieldvalue成为指针在数组$ fieldvalues中查找它的下一个值 - 因此通过上面提到的快捷语法将它添加到新数组`$ insertvalues中。

#2


5  

Add $fieldvalue to the end of the $insertvalues array.

将$ fieldvalue添加到$ insertvalues数组的末尾。

#3


1  

It inserts a new item at the end of the array.

它在数组的末尾插入一个新项。

Other languages tend to have an append or push function for this.

其他语言往往具有附加或推送功能。

#4


0  

It adds the value of $fieldvalue at the end of $insertvalues array. The [] creates an array and values of the specified variable are added to it at the end each time.

它在$ insertvalues数组的末尾添加了$ fieldvalue的值。 []创建一个数组,每次在末尾添加指定变量的值。

#5


0  

I think, This is variable for New Array.

我想,这对New Array来说是可变的。