PHP: Подсчет элементов в массиве — PHP шаг за шагом

Функция просто считает элементы массива —  count($arr). Собственно больше от нее ничего не требуется. Я использовал для перебора куска кода json, который пришел в ответ от API Youtube.

# code… $arr = file_get_contents($file); $request = json_decode($arr, true); $result = count($request[items]); foreach ($request[items] as $key => $value) { # code… echo $request[items][$key][snippet][title] . ‘
‘; echo $request[items][$key][snippet][description] . ‘
‘; } # code…

# code…

$arr = file_get_contents($file);

$request = json_decode($arr, true);

$result = count($request[items]);

foreach ($request[items] as $key => $value) {

  # code…

  echo $request[items][$key][snippet][title] . ‘
‘;

  echo $request[items][$key][snippet][description] . ‘
‘;

}

# code…

Функция на php.net

github-bb449e0ffbacbcb7f9c703db85b1cf0b-300x111-8991478