I wrote a script that combines the results equally from several arrays. The script works well, but I would like to do it more easily. My knowledge of php programming is poor. I have a question for experienced programmers, do you have any idea how can I get the same result using a better solution?
My code:
<?php
$a = array('a','a','a','a','a','a','a','a');
$b = array('b','b','b','b','b','b','b','b');
$c = array('c','c','c','c','c','c','c','c');
$count = count(array_merge($a, $b, $c));
$results = array();
for ($i=1; $i<$count; $i++){
if (isset($a[$i]) && !empty($a[$i])){ $results[] = $a[$i]; }
if (isset($b[$i]) && !empty($b[$i])){ $results[] = $b[$i]; }
if (isset($c[$i]) && !empty($c[$i])){ $results[] = $c[$i]; }
}
print_r($results); // array(a, b, c, a, b, c ..)
?>