Create an existing array array

2

I have the following line of code:

$valores = implode(", ", array_values($dados));

and by giving var_dump(array($valores)); the following information is returned:

  

array (1) {     [0] = >     string (26) "Igor, Teste, [email protected]"   }

However, I need each item to be returned in a new array (in this case, an array with 3 items). That is, it would create an array of that other array($valores) .

What is the best way to do this?

EDITED

I've tried to use explode :

$arrValores = array($valores);
$itemValores = explode(", ", $arrValores);

foreach($itemValores as $item) {
    $item;
}

var_dump($item);

However, what is returned to me is:

  

string (5) "Array"

Thanks!

    
asked by anonymous 18.04.2015 / 21:13

1 answer

1

If you need to use implode , then you can declare two variables, one for the formed string and another for array :

$valoresArray = array_values($dados);
$valoresStr = implode(", ", $valoresArray);

var_dump($valoresArray);
var_dump($valoresStr);
    
18.04.2015 / 21:28