U
U
Uzair Izha2015-10-29 20:01:25
PHP
Uzair Izha, 2015-10-29 20:01:25

How to make one array from arrays containing one variable?

I have a variable $a, if I do print_r($a), then it is displayed
Array ( [0] => 22 ) Array ( [0] => 2 ) Array ( [0] => 6, 7 )
How to do one array from that? It is important that the number of arrays in a variable can be different.

Answer the question

In order to leave comments, you need to log in

4 answer(s)
S
Sergey Petrov, 2015-10-29
@sergoslav_0

$result = array();
foreach($a as $_a)
{
    $result = $result + $_a;
}

S
Sergey, 2015-10-29
Protko @Fesor

If I understand correctly, and you want to
do
something from:
1) array_column
2) cycles
3) array_walk_recursive
4) RecursiveIteratorIterator and cycle

S
Stalker_RED, 2015-10-29
@Stalker_RED

A few hours ago, I gave you a code that collects all these values ​​into one array.
How to connect arrays?

I
inDeepCode, 2015-10-29
@inDeepCode

The fact is that print_r($a) can return a result of the form: Array ( [0] => 22 ) Array ( [0] => 2 ) Array ( [0] => 6, 7 )
only if it was called 3 (three) times.
those. your variable IS an array with one argument [0] that changes each time print_r($a) is called.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question