Programming Learning Diary

php foreach의 이해

페이지 정보

작성일 20-10-06 14:04

본문

                        // 방식 1
                        echo '방식1<br>';
                        $prices = array(
                            'Tires'=>100,
                            'Oil'=>10,
                            'Spark Plugs'=>4
                        );
                        foreach ($prices as $key => $value) {
                            echo $key.'->'.$value.'<br>';
                        }
                        echo '<br><br>';
                        // 방식 2
                        echo '방식2<br>';
                        $array = array("1""2""3""4""5""6""7""8");

                        foreach($array as $val) {
                            echo $val.'<br>'
                        }



결과

 0730c24f5c61a59ec9589ae1b1ce9701_1601960810_7036.png 

댓글목록

등록된 댓글이 없습니다.