Answer the question
In order to leave comments, you need to log in
Why is the array not formed in foreach?
Hello.
Why is the array not formed?
$outbad = array();
$outgood = array();
foreach((array)$emails as $key=>$e){
if (да){
$outgood[] .= $emailadress['dfgh'] . " хороший адрес"; // и такой вариант
} else{
$outbad[] .= array($emailadress . " плохой адрес"); // и такой вариант
}
echo $outgood;
echo $outbad;
$outbad[] = array($emailadress . " плохой адрес");
$outgood[] = $emailadress['dfgh'] . " хороший адрес";
Answer the question
In order to leave comments, you need to log in
And emails - what is it?
$ems = array('abc', 'def');
$outbad = array();
$outgood = array();
foreach ($ems as $val) {
if (true) {
$outgood[] = $val.' - OK';
} else {
$outbad[] = $val.' - FAIL';
}
}
echo $outgood;
echo $outbad;
from the ceiling because you take variables) you are in a cycle, use either a key or a variable that distributes $key $e. push or so $outgood[] = $e or array_push($outgood, $e);
foreach($emails as $key=>$e){
if (да) {
$outgood[] = $e . " хороший адрес";
} else {
$outbad[] = [$key . " плохой адрес"];
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question