I
I
Ilshat Gayanov2018-03-12 07:58:31
PHP
Ilshat Gayanov, 2018-03-12 07:58:31

How to group array values ​​into a variable?

How to group the values ​​of the array into one variable from this array, in the end I want to get 1,2,3.

$this->allInput = $request->all();
    $arrIDsOrder = [];
    $ordersInput = $this->allInput['orders'];
    foreach ($ordersInput as $item) {
        $arrIDsOrder[] = $item['id'];
        $this->allArray = $item['id'];
    }
    dump($arrIDsOrder);

5aa607bfbd8b7162234507.png

Answer the question

In order to leave comments, you need to log in

1 answer(s)
B
berzhikeev, 2018-03-12
@berzhikeev

If we are talking about transforming an array into a variable, there is an implode

$array = array('имя', 'почта', 'телефон');
$comma_separated = implode(",", $array);

or
$this->allInput = $request->all();

    $string = implode(",", $this->allInput['orders']);

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question