Архив

Август 2019

Всего: 7 записей

php save create dir

Для автоматического создания папок при использовании file_put_contents

function save_to_dir($to,$content){
	$path=pathinfo($to);
	if(!file_exists($path['dirname'])){
		mkdir($path['dirname'],0777,true);
	}
	return file_put_contents($to,$content);
}

owl carousel n from all

var owl=$('#owl');
owl.owlCarousel({
	loop:true,
	margin:0,
	items:1,
	dots:true,
	nav:true,
	navText:['<i class="fa fa-angle-left"></i>','<i class="fa fa-angle-right"></i>'],
});
owl.on('changed.owl.carousel',function(e){
	$('.counter span').text(e.page.index+1);
});
<div class="owl-carousel owl-theme" id="owl">
	<?php
	foreach($items as $item){?>
		<div class="item"></div>
	<?}?>
</div>
<div class="counter"><span>1</span> | <?=count($items)?></div>

php copy create dir

Создавать целевую папку, если такая не существует перед копированием. Использовать вместо функции copy:

function copy_to_dir($from,$to){
	$path=pathinfo($to);
	if(!file_exists($path['dirname'])){
		mkdir($path['dirname'],0777,true);
	}
	if(!copy($from,$to)){
		return false;
	}
	return true;
}