Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/246.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 使用foreach比较两个数组的问题_Php_Arrays - Fatal编程技术网

Php 使用foreach比较两个数组的问题

Php 使用foreach比较两个数组的问题,php,arrays,Php,Arrays,对不起,我的英语有问题,因为我查找相同的字段值,当我找到相同的值时,我会打印一条消息,如果我找不到相同的值,我会打印一条错误消息,但此错误消息会被重新编写,如果它们不是相同的值,我想打印一次此代码: foreach($row2 as $key => $value) { echo $value['event_title'].'<br/>'; if(isset($_SESSION['account_id'])) {

对不起,我的英语有问题,因为我查找相同的字段值,当我找到相同的值时,我会打印一条消息,如果我找不到相同的值,我会打印一条错误消息,但此错误消息会被重新编写,如果它们不是相同的值,我想打印一次此代码:

foreach($row2 as $key => $value)
    {
        echo $value['event_title'].'<br/>';
        if(isset($_SESSION['account_id']))
        {
            $query3 = Connexion::getConnexion()->prepare('SELECT COUNT(event_id) AS nbr,account_id,event_id ,account_event_place_reserved FROM account_event WHERE account_id =:id');
            $query3->bindParam(':id',$_SESSION['account_id'],PDO::PARAM_INT);
            $query3->execute();
            $row3 = $query3->fetch(PDO::FETCH_ASSOC);
            //$query3->closeCursor();
            //print_r($row3);

            if($row3['nbr'] > 0)
            {
                $query4 = Connexion::getConnexion()->prepare('SELECT account_id,event_id ,account_event_place_reserved FROM account_event WHERE account_id =:id GROUP BY event_id');
                $query4->bindParam(':id',$_SESSION['account_id'],PDO::PARAM_INT);
                $query4->execute();
                $row4 = $query4->fetchAll(PDO::FETCH_ASSOC);
                $query4->closeCursor();

                foreach($row4 as $key => $value2)
                {
                    //print_r($value2);
                    echo $value2['event_id'].'========='.$value['event_id'];
                    if($value2['event_id'] == $value['event_id'])
                    {
                        echo " vous etes inscrit a cet evenement"."<br/><br/>";


                     }
                     else
                     {
                     ?>
                        <a href='#' class='event_register'>  s inscrire a l evenement</a><br/><br/>
您将覆盖此行中的$key

foreach($row4 as $key => $value2)

你可以休息一下;在得到所需内容后停止foreach循环


此外,在循环中执行SQL查询不会很快,请考虑使用来自Actudio事件的SELECT*事件,其中IDS

中的ActudioID可能会提供帮助,如果您提供了您真正想要看到的输出…
foreach($row4 as $key => $value2)