How to looping multi array using foreach()
? Or how to define $looping
on for()
? I'm tired of using AND
logic on foreach()
.
This is my code:
<?php
$b=["a","b","c","d","5"];
$a=["1","3","4","5"];
foreach($a as $a && $b as $b) {
echo $a.$b;
}
// AND logic Error
$tipe=trim(fgets(STDIN));
$post=trim(fgets(STDIN));
if($tipe == "1") {
$url="http://example.com/api"
$postdata="post_data={$post[$x]}";
}
for($x=0;$x<10;$x++) {
$ch=curl_init();
curl_setopt($ch, CURLOPT_URL,$url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS,$postdata);
curl_setopt($ch, CURLOPT_POST, 1);
curl_exec($ch);
}
// $x not defined