Kindly help me with my code:
$a[1]='cloropil';
$a[2]='rodopayta';
$r=2;
$c=1;
$f= while($c<=$r){ echo $a[$c];;
$e = $c++ };
while($c<=$r){
echo $f;
$r++;
}
while($c<=$r){
echo $e;
$r++;
}
I want its output to be like this:
$a[1]='cloropil';
$a[2]='rodopayta';
$r=2;
$c=1;
while($c<=$r){
echo $a[$c];
while($c<=$r){
echo $a[$c];
$c++;
}
$c++;
}
How ever the out put is blank. it should even display at least "cloropil". Is this even possible? I want to display something like this:
cloropilcloropil cloropilrodopyta rodopytacloropil rodopytarodopyta
thank you very much in advance.
I think this may be what you are looking for?:
<?php
$a[]='cloropil';
$a[]='rodopayta';
// You first iterate over each
for($i = 0; $i < count($a); $i++)
{
// As you iterate through the first round, you iterate
// again to match pairs but include the first iteration
// value with this second
foreach($a as $val)
echo $a[$i].'=>'.$val.'<br />';
}
?>
Gives you:
cloropil=>cloropil
cloropil=>rodopayta
rodopayta=>cloropil
rodopayta=>rodopayta