function randomString($length){ // generated one random symnol
$characters = 'йцукенгшщзхъфывапролджэячсмитьбюё';
$charactersLength = mb_strlen($characters);
$randomString = '';
for ($i = 0; $i <$length ; $i++) {
$randomString .= mb_substr($characters,rand(0, $charactersLength - 1), 1);
}
return $randomString;
}
echo randomString(15);
$oldDir = './old_files';
$newDir = './new_files';
$files = array_slice(scandir($oldDir), 2);
$keys = [];
foreach ($files as $file) {
$keys = array_merge($keys, explode("\n",file_get_contents($oldDir.'/'.$file)));
}
$keyChunks = array_chunk($keys, 3);
foreach ($keyChunks as $key=>$chunk) {
file_put_contents($newDir.'/'.($key+1), implode("\n",$chunk));
}
$json = '{
"VM_set_PV_args":"",
"VM_set_PV_bootloader":"eliod",
"VM_set_other_config":{
"install-repository":"http:\/\/mirror.yandex.ru\/debian\/",
"install-distro":"debianlike",
"debian-release":"trusty",
"install-arch":"i386"
}
}';
$arr = json_decode($json, true);
echo $arr['VM_set_PV_bootloader'];
foreach ($arr['VM_set_other_config'] as $key => $val) {
echo $val;
}
<?php
$id = 1;
$arrayName = 'tmpl_' . $id;
global $$arrayName;
($$arrayName)[] = 'string';
var_dump($$arrayName);