function fixArray($input){
$output = [];
foreach($input as $value){
if(preg_match("/^0(\d+.*$)/", $value, $match)){
$output[] = "0";
$output[] = $match[1];
}else{
$output[] = $value;
}
}
return $output;
}
$getPHPInfo = function () {
ob_start();
phpinfo();
$result = ob_get_contents();
ob_clean();
return $result;
};
echo "123 {$getPHPInfo()}";
<?php
// ... формируем путь к картинке $fileLocation
//Расширение картинки тоже узнать нужно будет, если оно может быть разным
header("Content-Type: image/png");
//Неплохо добавить заголовок с кэшем, чтоб браузер не тянул этот ужас еще раз
header("Cache-Control: max-age=86400");
header("Pragma: cache");
header("Expires: ". date(DATE_RFC2822, time() + 86400));
$fileHeader = fopen($fileLocation, 'r', false);
$response = ""; //тут можно отдать картинку заглушку, если картинка не найдена по запросу.
if ($fileHeader) {
$response = stream_get_contents($fileHeader);
fclose($fileHeader);
}
exit($response);
function request($endpoint, $method, $data){
$ch = curl_init($endpoint);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, $method);
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($data));
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, [
'Content-Type: application/json'
];
$result = curl_exec($ch);
if (empty($result)) {
return [
'status'=>false,
'error'=>curl_error($ch)
];
}
return [
'status'=>true,
'response'=>$result
];
}
$period = new DatePeriod(
new DateTime('2019-01-21'),
new DateInterval('P1D'),
new DateTime('2019-01-28')
);
$dates = [];
foreach($period as $date){
$dates[] = $date->format("Y-m-d");
}
$where = " WHERE p.date IN ('" . implode(",'", $dates) . "')";
$data[$product][$price][] = $date;
////.......
foreach($data[$product][$price] as $datesInDb){
$missing = array_diff($dates, $datesInDb);
}
INSERT IGNORE INTO prices (columns)
VALUES (valueList),
(valueList),
...
function fakeIncrement($now, $startTimer = "2018-12-03 08:10:53", $tickPerHour = 5){
$startDate = strtotime($startTimer);
$seconds = $now - $startDate;
$offset = (int)date('H', $now);
$offset = $offset % $tickPerHour;
return (int)($seconds / 3600) * $tickPerHour + $offset;
}
for($i=0;$i<50;$i++){
echo fakeIncrement(time() + $i * 3600)."<br>";
}