3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php $categories = array("MainCategory" => array(0,0,0), 'SubCategory' => array(1,7,7,7,7,1), 'Keyword' => array()); $mainArray = $categories['MainCategory']; $subArray = $categories['SubCategory']; $keyArray = $categories['Keyword']; if (count($mainArray) === 0) { $mainArray = array(""); } if (count($subArray) === 0) { $subArray = array(""); } if (count($keyArray) === 0) { $keyArray = array(array('lastname', 'email', 'phone')); } foreach ($subArray as $subcat) { foreach ($mainArray as $cat) { foreach ($keyArray as $keys) { echo $cat; echo $subcat; echo implode(',',$keys); } } }
based on qJJTN
Output for 4.3.0 - 7.2.0
01lastname,email,phone01lastname,email,phone01lastname,email,phone07lastname,email,phone07lastname,email,phone07lastname,email,phone07lastname,email,phone07lastname,email,phone07lastname,email,phone07lastname,email,phone07lastname,email,phone07lastname,email,phone07lastname,email,phone07lastname,email,phone07lastname,email,phone01lastname,email,phone01lastname,email,phone01lastname,email,phone