$color_arr = array("red","green","white");
$list_arr_two = array("a","b","c","d","e","f");
for ex -: a = red;
b = green;
c = white;
d = red;
e = green;
f = white;
I just need to get repeat color once all array color repeated completed.
>Solution :
please try the below code:
<?php
$color_arr = array("red","green","white");
$list_arr_two = array("a","b","c","d","e","f","sd");
$i=0;
$color_length = count($color_arr) -1 ;
foreach($list_arr_two as $key=>$val)
{
echo $colorCode = $color_arr[$i];
echo "<br/>";
$i++;
if($i > $color_length)
{
$i =0;
}
}
?>