Skip to content

Instantly share code, notes, and snippets.

View bagart's full-sized avatar
🏠
Working from home

BAGArt bagart

🏠
Working from home
View GitHub Profile
<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)
);
}
<?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)) {
<?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];