简体   繁体   English

Laravel,如何使用索引获取数组值?

[英]Laravel, how do I get the array values using their index?

How do I get array values using their index, that is, using index 0 until 20 as shown in the picture below.如何使用它们的索引获取数组值,即使用索引 0 到 20,如下图所示。 I wanted to get the specific value, using index number 3 for example.我想获得特定值,例如使用索引号 3。

在此处输入图片说明

$my_array = [0,1,2,3,4,5,6,7,8,9,];

您需要数组编号5,因此请执行以下操作:

$data = array_keys($my_array, 5);

you can use :您可以使用 :

foreach( $array as $index => $element )
{ 'show'. $index . '=>'. $element }

试试这个:假设您有$ data作为数组,并且要打印第3个元素,那么$ data [3]将给您第3个元素。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何在 Laravel 中循环嵌套数组以根据该数组中键值的条件获取数组 - How do I loop a nested array in laravel to get an array based on conditions of key values from that array 如何在 laravel 中使用 foreach 获取数组值 - How to get array values using foreach in laravel 如何使用 JavaScript 获取 Laravel controller 的所有值到索引? - How to get all values from Laravel controller to index using JavaScript? 如何将数组放入字符串中,然后使用laravel 5索引该字符串 - How do you put an array into a string and then index the string using laravel 5 如何从数组中获取值? - How do I get the values from an array? laravel如何验证数组索引和值 - laravel how to validate array index and values 如何从foreach数组输出某些索引值? - How do I output certain index values from a foreach array? 如何使用php获取多维数组特定索引中的值的总和? - How to get sum of values in specific index of multidimensional array using php? 如何从数组中获取索引,该索引是使用foreach循环创建的,并且位于文本文件中? - How do I get an index out of an array, that was created using a foreach loop, and lives inside a text file? 如何从Laravel中的数组获取值列表? - How can i get list of values from array in laravel?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM