M
M
Murad_Geraev2021-12-31 02:39:08
PHP
Murad_Geraev, 2021-12-31 02:39:08

How to enumerate an array?

I get an array of properties, I need one value for each element from there. I'm new to php, I just didn't write like that, I've just been struggling with this for 3 hours, in total I got this
61ce44c71b9e1821229236.jpeg
How do I number the first level array so that I can access it?
61ce45909f45b926680717.jpeg
It should look like this:
(for example 3 array)
[3]=>Array
(
[0]=>1
[1]=>10
[2]=>2
[3]=>20
[4]=>31
[ 5]=>16
[4]=>Array (etc.)
If you help I will be very grateful

Answer the question

In order to leave comments, you need to log in

1 answer(s)
I
Igor, 2021-12-31
@Lopar

I don't understand shit, so I'll answer as I understand.

$array = [1, -20, 'tango', 'whiskey',];
/* echo $array[0]; // 1
 * echo $array[1]; // -20
 * echo $array[2]; // tango
 * echo $array[3]; // whiskey
*/

$array = ['foo' => 'bar', 'baz' => 27,]
/* echo $array[0]; // bar
 * echo $array[1]; // 27
 * echo $array['foo']; // bar
 * echo $array['baz']; // 27
*/

Did you mean it, author?

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question