php - Duplicate array elements and append to the same array -
is there way duplicate existing values in array , append them same array? here's can think pf
php
$names = array('tom', 'dick', 'hairy'); $names_new = $names; $duplication = 3; for($i = 0; < $duplication; $i++) { for($j = 0; $j < count($names); $j++) { $names_new[] = $names[$j]; } }
$names = array('tom', 'dick', 'hairy'); $names2 = array_merge($names, $names);
$names2 contain array want.
documentation: array_merge
Comments
Post a Comment