M
M
McMike2016-11-01 13:35:50
Yii
McMike, 2016-11-01 13:35:50

Is it possible to get a one dimensional array of values ​​in PHP?

There is an array
[0=>'value1', 1=>'value2', ...]
is it possible to get a one-dimensional array of values ​​from it without explicitly bypassing it
['value1', 'value2']
by Php or Yii2 functions

Answer the question

In order to leave comments, you need to log in

4 answer(s)
V
Vitaliy Orlov, 2016-11-01
@McMike

a strange question, because ['value1', 'value2'] is the same as [0=>'value1', 1=>'value2', ...]

print_r(['value1', 'value2']);
print_r([0=>'value1', 1=>'value2']);

M
Maxim Fedorov, 2016-11-01
@qonand

use the array-values ​​function

D
Dmitry, 2016-11-01
@slo_nik

Good afternoon.
How to bypass the array in php has already been suggested to you by Maxim Fedorov.
yii2 has a helper, ArrayHelpers . You can use it to process arrays.

M
McMike, 2016-11-02
@McMike

Yes, I'm sorry, I did not understand what I saw.
It seemed to me that these are string keys '0', '1'
Xdebug set, var_dump began to print arrays differently

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question