[Array] What is the error? This post was last edited by burner from 2015-04-011:5& lt ;? Php $ rc & nbsp; array (07-12 & gt; Reunion, & nbsp; 07-21 & gt; credit repayment, & nbsp; 07-23 & gt; purchase items); $ da [array] Where is the error?
This post was last edited by burner at 13:51:31
$ Rc = array ("07-12" => "reunion", "07-21" => "credit repayment ", "07-23" => "purchasing products ");
$ Date = "07-23 ";
Foreach ($ rc as $ key => $ value ){
If ($ key = $ date ){
Echo "script" alert ('". $ key." memo: ". $ value."') script ";
Break;
} Else {
Echo "script" alert ('No reten') script ";
Break;
}
}
?>
If the third line is: $ date = "07-12", a prompt box is displayed: 07-12 memo: Reunion
If the third line is: $ date = "07-21", or: $ date = "07-23", it should be the same as above, but the prompt box is displayed: no memo
Where is the error?
------ Solution ----------------------
$ Rc = array ("07-12" => "reunion", "07-21" => "credit repayment ", "07-23" => "purchasing products ");
$ Date = "07-23 ";
$ Msg = '';
Foreach ($ rc as $ key => $ value ){
If ($ key = $ date ){
$ Msg = "script" alert ('". $ key." memo: ". $ value."') script ";
Break;
}
}
If (! $ Msg) $ msg = "script" alert ('No memos ') script ";
Echo $ msg;
Think about why