1491 gün önce Txt dosyasına veri yazdırma
sorusunu cevapladı.
file_put_contents('ornektext.txt', json_encode($dizi, JSON_PRETTY_PRINT | JSON_UNESCAPED_UNICODE));
1491 gün önce Laravel tarih ayarlaması(tarih bulma)
sorusunu cevapladı.
anladığım kadarıyla şöyle bişey yapmak istiyorsun.
Başlangıç tarihini ve iş gününü verip bitiş tarihini alıcaksın.
function number_of_working_days($from, $to) {
$workingDays = [1, 2, 3, 4, 5]; # date format = N (1 = Monday, ...)
$holidayDays = ['*-01-01', '*-04-23', '*-05-01', '*-05-19', '*-07-15', '*-08-30', '*-10-29']; # variable and fixed holidays
// 1 Ocak, 23 Nisan, 1 Mayıs, 19 Mayıs, 15 Temmuz, 30 Ağustos, 29 Ekim
$from = new DateTime($from);
$interval = new DateInterval('P1D');
$periods = new DatePeriod($from, $interval, $to * 2);
$days = 0;
$d = [];
foreach ($periods as $period) {
if (!in_array($period->format('N'), $workingDays)) continue;
if (in_array($period->format('Y-m-d'), $holidayDays)) continue;
if (in_array($period->format('*-m-d'), $holidayDays)) continue;
if($days >= $to){
break;
}
$d[] = $period->format('Y-m-d');
$days++;
}
return $d;
}
echo "<pre>";
print_r(number_of_working_days('2021-11-01', 30));
echo "</pre>";
1491 gün önce bir değişkendeki sayıyı array içinde bulmak
sorusunu cevapladı.
var a = "3";
const numbers = ["0", "1", "2", "3", "4", "5", "6", "7", "8", "9"];
let i = numbers.findIndex(x => x == a);
console.log(i) // Output: 3
// eğer array içerisinde bulunmayan bir değeri aratırsan -1 döner.
1492 gün önce Laravel tarih ayarlaması(tarih bulma)
sorusunu cevapladı.
function number_of_working_days($from, $to) {
$workingDays = [1, 2, 3, 4, 5]; # date format = N (1 = Monday, ...)
$holidayDays = ['*-01-01', '*-04-23', '*-05-01', '*-05-19', '*-07-15', '*-08-30', '*-10-29']; # variable and fixed holidays
// 1 Ocak, 23 Nisan, 1 Mayıs, 19 Mayıs, 15 Temmuz, 30 Ağustos, 29 Ekim
$from = new DateTime($from);
$to = new DateTime($to);
$to->modify('+1 day');
$interval = new DateInterval('P1D');
$periods = new DatePeriod($from, $interval, $to);
$days = 0;
foreach ($periods as $period) {
if (!in_array($period->format('N'), $workingDays)) continue;
if (in_array($period->format('Y-m-d'), $holidayDays)) continue;
if (in_array($period->format('*-m-d'), $holidayDays)) continue;
$days++;
}
return $days;
}
echo number_of_working_days('2021-01-01', '2022-01-01');
// Output: 255
$workingDays Cumartesi ve Pazar hariç tüm günleri hesapla
$holidayDays Resmi tatilleri hariç tut.
Orjinali için https://stackoverflow.com/a/19221403
1492 gün önce Satır sayısı hesaplama
sorusunu cevapladı.
div içerisinde yapıyorsan value yerine innerHTML kullanmalısın.
let txt = document.getElementById('txt').innerHTML
console.log(txt.split('\n').length) // output: 10
1492 gün önce sql sorusu
sorusunu cevapladı.
sql e kayıt ederken şöyle kayıt et.
echo implode(',' , $_POST['name']); // 1,3
sqlden veriyi çekerkende FIND_IN_SET kullanarak idlere göre isimleri çekersin.
SELECT Users.Id, Users.Name FROM Users INNER JOIN OtherTable ON Users.Id = OtherTable.uId WHERE FIND_IN_SET(Users.Id, OtherTable.nameIds)
// verilerin 2 ayrı tabloda olduğunu düşünerek bu şekilde yaptım.
// OtherTable.nameIds = 1,3
1492 gün önce Satır sayısı hesaplama
sorusunu cevapladı.
<textarea id="txt">1 deneme
2 deneme
3 deneme
4 deneme
5 deneme
6 deneme
7 deneme
8 deneme
9 deneme
10 deneme</textarea>
let txt = document.getElementById('txt').value
console.log(txt.split('\n').length) // output: 10
php için
echo count(explode('\n', $txt));
1496 gün önce CSS Seçicileri İle Eleman Nasıl Seçilir?
sorusunu cevapladı.
bildiği kadarıyla css'te önceki elemanı seçemiyorsun eğer şöyle olsa çalışırdı.
<button> Bas </button>
<input placeholder="YAZ">
button:active + input::placeholder {
color:red;
}
1500 gün önce document.querySelector(".deyisken") -> $("deyisken")
sorusunu cevapladı.
degisken classındaki tüm elementleri seçmek istiyorsan document.querySelectorAll('.degisken') kullanmalısın.
1505 gün önce Php ile online takibi
sorusunu cevapladı.
Buradaki örnek işinize yarayabilir.