Store all array positions in a variable?

2

I have an array that contains 3 positions, each of which stores a long text, how can I store all three of the array positions in a single variable? for example:

Array ['Gol', 'Pallium', 'Celtic']

$ AllAsMarcas = // All positions in the array above.

Unfortunately, I can not because my code overwrites to the last position, so the previous positions are lost.

Thank you in advance!

    
asked by anonymous 15.09.2015 / 02:24

1 answer

0

implode () , transforms an array into a string, the function accepts two arguments the first one is the delimiter which the items in the array will last, the second is the array. If you only enter an argument (array) the output string will be all cast.

<?php
$arr = Array('Gol','Pálio','Celta', 'Audi A3');
echo $str = implode('#', $arr);
echo $str = implode($arr);

Output:

Gol#Pálio#Celta#Audi A3
GolPálioCeltaAudi A3

To do the opposite process use the function explode () .

    
15.09.2015 / 14:25