$ololo = (new Ololo())->lol();
$route->onHttpError(
function ($code) {
$instance = "frontend\\controllers\\Home";
switch ($code) {
case 404:
case 405:
header("HTTP/1.1 404 Not Found");
call_user_func([new $instance, "error404"], self::$answer[0][1]);
break;
case 403:
header("HTTP/1.1 403 Forbidden");
call_user_func([new $instance, "error403"], self::$answer[0][1]);
break;
}
}
);
function r_array_search($needle, $haystack, $currentKey = "") {
foreach ($haystack as $key => $value) {
if (is_array($value)) {
$nextKey = r_array_search($needle, $value, $currentKey . "[{$key}]");
if ($nextKey) {
return $nextKey;
}
} else if ($value == $needle) {
return is_numeric($key) ? $currentKey . "[{$key}]" : $currentKey . "['{$key}']";
}
}
return false;
}
$GLOBAL = [
3515 => [
'sub_categories' => [
22916 => [
'sub_categories' => [
33221 => 'test'
]
],
]
],
35215 => [
'sub_categories' => [
221916 => 'test2'
]
],
];
print_r(r_array_search("test", $GLOBAL));
//[3515][sub_categories][22916][sub_categories][33221]
ob_get_contents
в помощь.<table>
<tr>
<td><?= $variable_1 ?></td>
</tr>
<tr>
<td><?= $variable_2 ?></td>
</tr>
</table>
$mail = new PHPMailer();
$variable_1 = "Привет";
$variable_2 = "Чухча";
ob_start();
require_once("template.php");
$body = ob_get_contents();
ob_end_clean();
.....
$mail->Body = $body;
.....
<?php
$pass = [];
$array = [
"name" => "value",
"anotherName" => "anotherValue"
];
foreach($array as $key => $value){
if (array_key_exists($key, $pass)) {
$pass[$key] = array_merge_recursive($pass[$key], $value);
} else {
$pass[$key] = $value;
}
}
?>
<html>
<head>
<script src="https://code.jquery.com/jquery-3.3.1.min.js"></script>
<script>
const variable = $.extend({}, <?= json_encode($pass) ?> );
$(function(){
$(".result").html(variable.anotherName);
});
</script>
</head>
<body>
<div class="result"></div>
</body>
</html>