Skip to content

Instantly share code, notes, and snippets.

@ha1t
Created August 31, 2018 10:46
Show Gist options
  • Save ha1t/021e1ac109c58153e2d08f5789c42931 to your computer and use it in GitHub Desktop.
Save ha1t/021e1ac109c58153e2d08f5789c42931 to your computer and use it in GitHub Desktop.
<?php
$rows1 = [['id' => 1], ['id' => 2]];
$rows2 = [[]];
$rows3 = [];
function pattern1($rows)
{
foreach ($rows as $row) {
if (!isset($row['id'])) {
echo "0件ですわあ";
} else {
echo $row['id'] . ':';
}
}
echo PHP_EOL;
}
pattern1($rows1);
pattern1($rows2);
pattern1($rows3);
@ha1t
Copy link
Author

ha1t commented Aug 31, 2018

$row1と$row2はforeachを通るけど、$row3はforeach自体通らない

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment