Skip to content

Instantly share code, notes, and snippets.

@saeedsajadi
Created August 6, 2017 11:35
Show Gist options
  • Save saeedsajadi/12c23122151b96c4f1409c857a5210eb to your computer and use it in GitHub Desktop.
Save saeedsajadi/12c23122151b96c4f1409c857a5210eb to your computer and use it in GitHub Desktop.
<?php
$arrResult = [
'R' => ['1', '2'],
'A' => ['1', '2', '3'],
'M' => ['1', '2'],
];
//R1A1M1
foreach ($arrResult['R'] as $item1){
foreach ($arrResult['A'] as $item2) {
foreach ($arrResult['M'] as $item3) {
echo 'R' . $item1 . 'A' . $item2 . 'M' . $item3;
echo '<br>';
}
}
}
//foreach ($arrResult as $key => $value) {
// foreach ($value as $item) {
// echo $key . $item;
// }
//}
/*function saeed($asli, $arr, $key, $counter)
{
foreach ($arr as $item) {
echo $key . $item;
if (count($asli) > $counter) {
$counter++;
saeed($asli, next($asli), key($asli), $counter);
}
echo '<br>';
}
}
foreach ($arrResult as $key => $values) {
echo $key;
foreach ($values as $value) {
echo $value;
foreach ($arrResult as $key => $values) {
echo $key;
foreach ($values as $value) {
echo $value;
echo "<br>";
}
}
}
}
saeed($arrResult, current($arrResult), key($arrResult), 0);*/
//array_walk($arrResult, 'saeed');
//function asghar($value, $key){
// return $value;
//}
//function saeed($value, $key)
//{
// if(is_array($value)){
// return $key . ' ' . array_walk($value, 'asghar');
// }
// print "$key <br>\n";
//}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment