$str = '[:en]Black Brown[:de]Black Brown[:]';
preg_match('/\[:en\]([^(\[:)]*)/', $str, $matches);
$str_en = $matches[1] ?? '';
echo $str_en;
$prev_char = null;
foreach ($categories as $category) {
$curr_char = mb_substr($category->description, 0, 1, 'utf-8');
if ($curr_char != $prev_char) {
if (isset($prev_char)) {
echo "</ul>\n";
echo "</section>\n";
}
$prev_char = $curr_char;
echo "<section>\n";
echo "<h2>$curr_char</h2>\n";
echo "<ul>\n";
}
echo '<li><a href="' . get_category_link($category->term_id) . '">' . $category->description . '</a></li>';
}
echo "</ul>\n";
echo "</section>\n";
$arr = [
["name" => "Austin"],
["name" => "Nashville"],
["name" => "Foldo"],
["name" => "Femosss"]
];
function arrayFilterFirstChar(array $arr, string $chr): array
{
return array_values(array_filter($arr, fn($val) => $val['name'][0] == $chr));
}
var_dump(arrayFilterFirstChar($arr, 'F'));
function arraySearchSubkey(array $array, string $needle): array
{
return array_filter(
$array,
function($key) use($needle) {
return strpos($key, $needle) !== false;
},
ARRAY_FILTER_USE_KEY
);
}
function arraySearchSubkey(array $array, string $needle): array
{
return array_filter($array, fn($key) => strpos($key, $needle) !== false, ARRAY_FILTER_USE_KEY);
}
:root {
font-size: 16px; // 1rem = 16px
}
div {
padding: .5rem; // 8px
}
$json = '{
"result": {
"Random ItemName": [
{
"user": "user1",
"time_upd": "2020-12-09 12:25:03"
}, {
"user": "user2",
"time_upd": "2020-12-09 12:25:03"
}, {
"user": "user3",
"time_upd": "2020-12-09 12:25:03"
}
]
}
}';
$data = json_decode($json, true);
$i = 0; // меняется в цикле
$user_name = $data['result']['Random ItemName'][$i]['user'];
$time_upd = $data['result']['Random ItemName'][$i]['time_upd'];
$user_name = $data['result'][array_key_first($data['result'])][$i]['user'];
$time_upd = $data['result'][array_key_first($data['result'])][$i]['time_upd'];
foreach ($data['result'] as $arrayKey => $arrayValue) {
foreach ($arrayValue as $arraySubvalue) {
$user_name = $arraySubvalue['user'];
$time_upd = $arraySubvalue['time_upd'];
// …
}
}
<script>
window.addEventListener('load', () => {
…
});
</script>
http_response_code(404);
exit;
header('Location: …', true, 301);
exit;
header('Location: …', true, 307);
exit;
if ($fh = fopen('/public/vag102020.csv', 'r')) {
while (($csvStr = fgetcsv($fh, 1024, ';')) !== false) {
$csvArr[] = $csvStr;
}
}
$weight = $line[5] ?? 0;