function getInfo(...$vars) {
$a = 'какой-то текст';
$b = 'что-то из базы';
$c = 'что-то из env переменных';
//итд
foreach($vars[0] as $var_name) {
$result[] = $$var_name;
}
return $result;
}
$result = getInfo(['a','b','c']);
print_r($result);
?>
Array
(
[0] => какой-то текст
[1] => что-то из базы
[2] => что-то из env переменных
)
$a = ["group.phantom", "group.god", "group.imperator", "group.general", "group.hermit", "group.soldier"];
$b = [
[
"permission" => "group.default"
],
[
"permission" => "group.phantom"
],
[
"permission" => "group.hermit"
],
[
"permission" => "group.imperator"
],
[
"permission" => "group.god"
],
];
function getItem($a, $b) {
foreach ($a as $item) {
foreach ($b as $data_arr => $data) {
if ($item == $data['permission']) return $item;
}
}
}
print getItem($a, $b);
$response = json_decode($response, true);
var_dump($response);
$arResult = json_decode($response, true);
var_dump($arResult);
$file = 'file.txt';
$file_strings_arr = file($file);
$strings_amount = sizeof($file_strings_arr);
$string_for_del = rand(0, $strings_amount - 1);
print $file_strings_arr[$string_for_del];
unset($file_strings_arr[$string_for_del]);
file_put_contents($file, implode('', $file_strings_arr));
$obj = (object)['test' => 'test'];
print_r($obj);
stdClass Object
(
[test] => test
)
$text = "text " . "$param" . "...";
$text = "text {$param}...";
$send .= "sudo screen -dmS screen_name docker run {$user_container } {$memory_container} -d -it --cpus '1' --memory={$mem}m"
<form class="mt-5" method="post" action="do_logout.php" style="display:none">
<button type="submit" class="btn btn-primary" id="submit_button">Logout</button>
</form>
<span style="cursor:pointer" onclick="document.getElementById('submit_button').click();">Log out</span>
<a style="<?if($lastprice < $lastprice) { echo 'color:red'; }else{ echo 'color:green'; }?>"><?echo (float)$lastprice;?>
<a style="<?if($firstrprice < $lastprice) { echo 'color:red'; }else{ echo 'color:green'; }?>"><?echo (float)$lastprice;?>
$firstprice = 1700;
<a style="<?if($firstrprice < $lastprice) { echo 'color:red'; }else{ echo 'color:green'; }?>"><?echo (float)$lastprice;?>
class Someclass
{
public static function getDate($k)
{
switch ($k) {
case "Y":
return date("Y");
break;
case "m":
return date("m");
break;
case "d":
return date("d");
break;
case "H-i-s":
return date("H-i-s");
break;
}
}
}
define('LOG_FILENAME', "{$_SERVER["DOCUMENT_ROOT"]}/logs/" . Someclass::getDate("Y") . "/" . Someclass::getDate("m") . "/" . Someclass::getDate("d") . ".txt");