This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
function three_asc(array $a) { | |
if (count($a) < 3) { | |
return false; | |
} | |
$min = $max = $new_min = 0; | |
for ($i = 1; $i < count($a); $i++) { | |
if ($min < $max) { | |
if ($a[$max] < $a[$i]) { | |
return [$min, $max, $i]; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
public function upload(Request $request): array | |
{ | |
$tmp_file = tmpfile(); | |
stream_copy_to_stream($request->getContent(true), $tmp_file); | |
fflush($tmp_file); | |
$tmp_file_name = stream_get_meta_data($tmp_file)['uri']; | |
$this->logger->debug("File uploaded to $tmp_file_name"); | |
$tmp_file_type = mime_content_type($tmp_file_name); | |
if (!in_array($tmp_file_type, $this->allowed_mime_types)) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<php | |
function implode_recursive(string $glue, array $pieces) { | |
return implode( | |
$glue, | |
array_map(function ($v) use ($glue) { | |
return is_array($v) ? implode_recursive($glue, $v) : $v; | |
}, $pieces) | |
); | |
} |