$cnt = count($records);
for($i = 0; $i < $len; ++$i) {
$next = $i + 1;
if($next < $len) {
echo $records[$next]['date'], ' - ';
}
echo $records[$i]['date'], ' ', $records[$i]['price'] ;
}
function dropUrlQuery(string $url = ''): string
{
$position = strpos($url, '?');
if($position) {
$url = substr($url, 0, $position);
}
return $url;
}
$sum = 0;
foreach ($posts as $post) {
foreach ($find_ratings as $find_rating) {
if ($find_rating->post_id === $post->id) {
$sum += $find_rating->rating;
}
}
}
echo $sum;
сумму из БД
$steamIds[] = $row['steam_id'];
$steamids = [ .... ];
$uuser = "http://api.steampowered.com/ISteamUser/GetPlayerSummaries/v0002/?key=".$steamauth['apikey']."&steamids=" . join(',', $steamids);
<?php
$text = 'Page title';
?>
<html>
<head>
<title><?= $text ?></title>
</head>
<body>
<h1><?= $text ?></h1>
<p>Lorem ipsum</p>
</body>
</html>
// исходный массив
$array = [10,20,35,0,123,0,12,676,324];
// ключи для проверки на 0
$check = [3,5];
if(array_intersect(array_keys(array_filter(array_combine(array_keys($array), array_values($array)))), $check)) {
echo 'good';
}
if(array_filter($array, function($value, $key) use ($check) { return in_array($key, $check) && $value != 0; }, ARRAY_FILTER_USE_BOTH)) {
echo 'good';
}
$json = json_decode($start);
if($json) {
foreach ($json as $key => $value) {
...
}
}
$array1 = ['красная шапочка', 'серый волк'];
$array2 = ['красная', 'серый'];
function rep($val)
{
global $array2;
return str_replace($array2, '', $val);
}
$array3 = array_map('rep', $array1);
print_r($array3);