$text = '90+3\' SGDGG p[gdsg] sadgcgbcvb';
echo preg_replace('~^[^a-z]+~i', '', $text);
$text = '$.ajax({type: "POST",url: "/dir1/dir2/ajax/ads",data: "view=list",dataType: "html",cache: false,success: function (data) {
}});';
$repl = 'ЗначениеДляЗамены';
$text = preg_replace('~url:\h"\K[^"]+(?=/ajax/ads)~', $repl, $text);
echo $text;
$str = 'Исходный текст и {{}}.';
$dir = 'blog\flowers.txt';
$str = preg_replace_callback(
'~{{\K(?=}})~',
function()use($dir){
return file_get_contents($dir);
},
$str
);
echo $str;
$str = 'Исходный текст и {{}}.';
$dir = 'blog\flowers.txt';
$str = str_replace('{{}}', '{{'. file_get_contents($dir) . '}}', $str);
echo $str;
$styles = [
'grid-2h',
'grid-2h',
'grid-1',
'grid-1',
'grid-4',
'grid-4'
];
shuffle($styles);
$total = count($styles);
$trigger = 1;
$buffer = [];
while ($trigger) {
foreach ($styles as $k => $style) {
if (count($buffer) == $total) {
$trigger = 0;
break;
}
$next = $styles[$k+1] ?? ($total - 1);
$next == $style ?: $buffer[] = $style;
}
}
print_r( $buffer );