search

Home  >  Q&A  >  body text

foreach usage

Help me explain the operating principle and the meaning of $diqusql.="'{$i}'"

$diqusql="diyu IN(";

foreach($diqu as $ i){

            $diqusql.="'{$i}',";

                                    $diqusql=rtrim($diqusql, ",")." )"

三 剑三 剑2170 days ago1017

reply all(2)I'll reply

  • 保哥后院

    保哥后院2019-01-02 16:48:11

    foreach is a statement that traverses an array. The standard usage is: foreach (data type identifier in expression)


    e.g:


    $person = array(
    "name1" => "peter",
    "name2" => "lisi"
    );
    foreach ($person as $ person_value) {
    echo "Name:" . $person_value;
    echo "<br>";
    }

    reply
    0
  • Cancelreply