PHP
- 10 ответов
- 0 вопросов
8
Вклад в тег
foreach by-value operates on a copy of the array
When used in the default by-value mode, foreach will now operate on a copy of the array being iterated rather than the array itself. This means that changes to the array made during iteration will not affect the values that are iterated.
$arr_copy = $arr;
foreach($arr_copy as $k=>$v) {
...
}
за тем исключением, что к переменной $arr_copy вы не имеете прямого доступа.SELECT
SUM( IF(post_id != 1, 1, 0) ) as one_count,
SUM( IF(post_id = 1, 1, 0) ) as two_count
FROM comments
WHERE user_id = $user_id