move_uploaded_file($_FILES["filename"]["tmp_name"], $upload_dir_name . '/' . $ClientName . "/" . $ContentTypeDir . '/' . $file_name);
$file_name
?move_uploaded_file($_FILES["filename"]["tmp_name"], $upload_dir_name . '/' . $ClientName . "/" . $ContentTypeDir . '/' . MyRandomGenerator::getString());
class MySingleMysqlConnection {
private static $instance;
private $connection;
private function __clone() {}
private function __construct() {
$this->connection = new MysqlConnection();
}
public static function getConnection(){
if (null === self::$instance){
self::$instance = new self();
}
return self::$instance->connection;
}
MySingleMysqlConnection::getConnection()
INT(11) UNSIGNED
INET_ATON
- это функция mysql /**
* @param array $input
* @param array $items
*
* @return int|null
*/
function compare(array $input, array $items)
{
foreach ($items as $index => $item) {
$compareResult = version_compare(implode('.', $input), implode('.', $item));
if ($compareResult <= 0) {
if ($compareResult === 0 || !array_key_exists($index - 1, $items)) {
return $index;
}
return $index - 1;
}
}
return null;
}
$items = [
[1, 1, 1],
[1, 2, 1],
[1, 2, 2],
[1, 5, 4],
[1, 5, 6],
[2, 1, 6],
[2, 2, 2],
];
$input = [1, 5, 5];
if (null === $index = compare($input, $items)) {
echo 'Элемент не найден';
} else {
echo "Элемент под номером {$index} является наиболее близким";
}
<form method="post">
<input name="name">
<input name="question[0][name]">
<input name="question[0][answer][]">
<input name="question[0][answer][]">
<input name="question[0][correct_answer]">
<input name="question[1][name]">
<input name="question[1][answer][]">
<input name="question[1][answer][]">
<input name="question[1][correct_answer]">
<input type="submit" value="save">
</form>
var_dump($_POST);
array (size=2)
'name' => string '' (length=0)
'question' =>
array (size=2)
0 =>
array (size=3)
'name' => string '' (length=0)
'answer' =>
array (size=2)
0 => string '' (length=0)
1 => string '' (length=0)
'correct_answer' => string '' (length=0)
1 =>
array (size=3)
'name' => string '' (length=0)
'answer' =>
array (size=2)
0 => string '' (length=0)
1 => string '' (length=0)
'correct_answer' => string '' (length=0)