(перевод, оригинал)
Поиграть с разметкой Markdown можно на демо-странице.
(перевод, оригинал)
Поиграть с разметкой Markdown можно на демо-странице.
$dataArr = [ | |
0 => 'EF001391', | |
1 => 'EF000228', | |
2 => 'EF000227', | |
]; | |
$debug_log = Yii::app()->runtimePath . '/DebugExport.log'; | |
$dataErr = print_r($dataArr, true); | |
file_put_contents($debug_log, $dataErr . PHP_EOL, FILE_APPEND); | |
================================ |
<?php | |
function json_sort(string $json, bool $objects=true, bool $arrays=false): string | |
{ | |
// uses a recursive lambda | |
$order = null; | |
$order = function ($json) use (&$order, $objects, $arrays) { | |
// sort sub-trees | |
foreach ($json as $key => $value) { | |
if (is_array($value) || is_object($value)) { |
$tmpFile = $sourceFileName; | |
$fileName = $this->csvFilePath . DIRECTORY_SEPARATOR . $this->csvFileName; | |
$command = 'xls2csv -c\; -q0 -s cp1251 -d cp1251 ' . $tmpFile . ' > ' . $fileName; | |
exec($command); | |
unlink($tmpFile); |
protected function getFilename(UploadedFile $file): string | |
{ | |
$hash = sha1_file($file->tempName); | |
$name = substr_replace($hash, '/', 3, 0); | |
$name = substr_replace($name, '/', 7, 0); | |
return $name . DIRECTORY_SEPARATOR . $file->extension; | |
} |
// HTML form | |
<form action="upload.php" method="post" enctype="multipart/form-data"> | |
<input type="file" name="images[]" multiple> | |
<button type="submit">Загрузить</button> | |
</form> | |
<?php | |
// File upload.php | |
// Если в $_FILES существует "images" и она не NULL | |
if (isset($_FILES['images'])) { |
Как удалить любую папку, в т.ч. и .idea, и лишние файлы из Git | |
Создаем файл .gitignore в корне репозитария с содержимым: | |
.idea | |
logs/ | |
------------------------------------------------------------------ | |
Подробнее можно ознакомиться на странице: https://git-scm.com/book/ru/v1/Основы-Git-Запись-изменений-в-репозиторий | |
Удаляем ненужные папки и файлы при синхронизации в Git репозиторий |
/** | |
* Преобразует SimpleXMLElement в array | |
* @param SimpleXMLElement $xml | |
* @return array | |
*/ | |
private static function xmlToArray($xml) { | |
$xml = (array) $xml; | |
if(empty($xml)) { | |
return null; |
# frontend | |
server { | |
listen 80; | |
server_name yii2.lo; | |
server_tokens off; | |
client_max_body_size 128M; | |
charset utf-8; | |
access_log /var/log/nginx/yii2-access.log main buffer=50k; |