I am trying to get a value repeated number of times the value of an array element
I have the following arrays
<?php
$a = array(1, 2, 3);
$b = array(3, 2, 5);
foreach ($b as $x) {
for ($i = 1; $i <= $x; $i++) {
echo print_r($i).'<br>';
}
}
Output:
11
21
31
11
21
11
21
31
41
51
I expect the output to be:-
1112233333
2
Answers
Here you go –
You can try this: