Search code examples
phparraysstringimplode

Convert a flat array into a delimited string


example

Array ( [0] => 1 [1] => 2 )

enter image description here

convert

echo "Number:".$array;

as a result I want you to print this Number: 1,2. print the arrangement cleanly

I want to put it in the right way.


Solution

  • <?php
    $array = array(1, 2);
    echo 'Number: ', implode(',', $array);
    ?>