LoginSignup
6
5

More than 5 years have passed since last update.

if(is_array())とforeachを少し格好良く

Last updated at Posted at 2013-07-24

どっかで見ただけなんだけど、どこで見たのか忘れたのでメモ。

<?php
$a = array(1, 2);
if(is_array($a)) foreach($a as $each){
    echo $each;
}

と、ifとforeachを同じ行に書ける。
構文的にどうなってるかは何となく想像が付く気がするけど、foreachってこういう存在なんだ。

6
5
1

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
6
5