$keys = ['title_bl', 'descr_bl', 'img_bl'];
$res = [];
foreach($arr as $value) {
$res[] = array_combine($keys, $value);
}
select title as title_bl, descr as descr_bl .... from ....
$res[] = $value;
$img = $_GET['img'];
// Тут проверки и прочее
$image = imagecreatefromstring('/dir/' . $img);
// Тут можно наложить водяной знак или уменьшить, превью типо
header('Content-Type: image/png');
imagepng($image);
foreach(array_slice(get_posts_best(), 2, 4) as $post) {
//
}
$image = imagecreatefromstring(file_get_contents('test.jpg'));
// получаем разеры исходника
$ix = imagesx($image);
$iy = imagesy($image);
// делаем холст с заливкой фона
$newimage = imagecreatetruecolor($ix, $iy);
$transparent = imagecolorallocatealpha($newimage, 255, 255, 255, 127);
imagefill($newimage, 0, 0, $transparent);
imagealphablending($newimage, true);
imagesavealpha($newimage, true);
// накладываем исходник на холст
imagecopyresampled($newimage, $image, 0, 0, 0, 0, $ix, $iy, $ix, $iy);
// берем вотермарку
$imageW = imagecreatefromstring(file_get_contents('logo.png'));
$wx = imagesx($imageW);
$wy = imagesy($imageW);
// для поворота нужен прозрачный холст
$new = imagecreatetruecolor($wx, $wy);
$transparent = imagecolorallocatealpha($new, 0, 0, 0, 127);
$rotate = imagerotate($imageW, 45, $transparent);
imagealphablending($rotate, true);
imagesavealpha($rotate, true);
// пересчет размеров после поворота
$ix = imagesx($rotate);
$iy = imagesy($rotate);
// наложение 50 50 начало от левого верхнего угла
imagecopyresampled($image, $rotate, 50, 50, 0, 0, $ix, $iy, $ix, $iy);
// сохранение
imagepng($image, 'testus.png', 9, PNG_ALL_FILTERS);
public function cmp($array, $key, $sort = 1) {
return uasort($array, function ($a, $b) use ($key, $sort) {
return $sort ? $a[$key] <=> $b[$key] : $b[$key] <=> $a[$key];
}
}
foreach (array_slice($array, 0, 12) as $buf) {
}
foreach (array_slice($array, 12) as $buf) {
}
<?php
return ['user' => 'admin','name' => 'GOD','pass' => '123123'];
$conf = require('conf.conf');
echo $conf['user'];
// save
file_put_contents('conf.conf', "<?php\n\n" . 'return ' . var_export($config, true) . ";\n");
ob_get_level() && ob_end_clean();
header($_SERVER['SERVER_PROTOCOL'] . ' 200 OK');
header('Content-Type: application/force-download');
header('Content-Description: inline; File Transfer');
header('Content-Transfer-Encoding: binary');
header('Content-Disposition: attachment; filename="' . $name . '";', false);
header('Content-Length: ' . $len);
$upload = new SplFileObject($url, 'rb');
while (!$upload->eof()) {
echo($upload->fgets());
}
flush();
exit;