/что-то\d+/
.$arr = explode(', ', explode('какой-то текст: ', $str)[1]);
preg_match_all('/[^ ,:]+(?!.*:)/', $str, $matches);
$arr = $matches[0];
preg_match_all('~<.+?>(.*?)<\/.+?>~', $str, $matches);
$result = $matches[1];
function getTexts($domNode) {
$result = [];
foreach ($domNode->childNodes as $n) {
if ($n->nodeType === XML_TEXT_NODE) {
$result[] = $n->nodeValue;
} else if ($n->nodeType === XML_ELEMENT_NODE) {
array_push($result, ...getTexts($n));
}
}
return $result;
}
$doc = new DOMDocument();
$doc->loadHTML($str);
$result = getTexts($doc);
$doc = new DOMDocument();
$doc->loadHTML($str);
$result = [];
foreach ((new DOMXPath($doc))->query('//text()') as $n) {
$result[] = $n->nodeValue;
}
'/^\+372((( |-)?\d){8,})$/'
. function makeTree($data, $levelField) {
$root = [];
foreach ($data as $d) {
$arr = &$root;
$level = 0;
while ($d[$levelField] > $level++) {
$arr = &$arr[count($arr) - 1]['children'];
}
$arr[] = array_merge($d, [ 'children' => [] ]);
}
return $root;
}
$tree = makeTree($data, 'depth');
SELECT COUNT(*) FROM users
$result[0] < 0
$teacherID = чему-то там равен, неважно...
$itemsByTeacherID = [];
foreach ($days as $day) {
foreach ($day['day_items'] as $item) {
if ($item['teacher'] === $teacherID) {
$itemsByTeacherID[$day['day']][] = $item;
}
}
}
$brands = array_filter($brands, function($n) {
return isset($n['alias']);
});
$grouped = [];
foreach ($products as $p) {
$grouped[$p['category-id']][] = $p['name'];
}
function groupData($data, $groupBy, $groupTo) {
$grouped = [];
foreach ($data as $t) {
$name = $t[$groupBy];
$grouped[$name][$groupBy] = $name;
unset($t[$groupBy]);
$grouped[$name][$groupTo][] = $t;
}
return array_values($grouped);
}
$grouped = groupData($arr, 'name', 'info');
function removeWords($str, $n) {
return implode(' ', array_slice(explode(' ', $str), 0, $n - 1));
}
echo removeWords("Бухгалтерский учет и анализ слонов", 3);