$string = 'привет';
echo mb_strtoupper(mb_substr($string, 0, 1)) . mb_substr($string, 1, mb_strlen($string));
// Привет
const link = document.getElementById('theme-link');
const lightTheme = '/css/light.css';
const darkTheme = '/css/dark.css';
let currentTheme = localStorage.getItem('theme');
(function(){
if( !currentTheme ) {
currentTheme = lightTheme;
localStorage.setItem('theme', currentTheme);
}
link.setAttribute('href', currentTheme);
})();
document.getElementById('theme-button').addEventListener('click', e => {
e.preventDefault();
if( currentTheme == darkTheme ) {
currentTheme = lightTheme;
}else {
currentTheme = darkTheme;
}
link.setAttribute('href', currentTheme);
localStorage.setItem('theme', currentTheme);
});
<?php
// Твои картинки из БД
$images = [
[
'src' => 'http://lorempixel.com/1920/1080/nature/1',
'caption' => 'Image #1',
'id' => 12 // Айди картинки в БД
],
[
'src' => 'http://lorempixel.com/1920/1080/nature/2',
'caption' => 'Image #2',
'id' => 15
]
];
?>
<script type="text/javascript">
const myImages = <?=json_encode($images)?>;
let myInitialPreview = [];
let myInitialPreviewConfig = [];
for( let i in myImages ) {
myInitialPreview.push(myImages[i].src);
myInitialPreviewConfig.push({
caption: myImages[i].caption,
key: i,
extra: { id: myImages[i].id }
});
}
$("#file_input").fileinput({
deleteUrl: 'delete.php', // Тут твой обработчик при удалении файла
overwriteInitial: false,
initialPreviewAsData: true,
initialPreview: myInitialPreview,
initialPreviewConfig: myInitialPreviewConfig
});
</script>
// delete.php
<?php
if( $image_id = filter_input(INPUT_POST, 'id', FILTER_VALIDATE_INT) ) {
// Удаляешь картинку из БД, $image_id = id удаляемой картинки
}
echo json_encode(['success' => 1]);
?>
for ($i = $elem; $i < sizeof($array)-$elem-1; $i++)
function shift($array, $elem)
{
$array[$elem] += 1 * 24 * 3600;
return $array;
}