1486 gün önce Uzak sunucudan php dosyası include veya require etmek
sorusunu cevapladı.
uzak sunucudan php dosyası include edemezsin ama api oluşturup uzak sunucuya gerekli parametreleri vererek sonuç alabilirsin.
1487 gün önce Panelden eklediğim Sabit Gider her ay otomatik olarak eklensin istiyorum.
sorusunu cevapladı.
kodlarını paylaşabilirsen daha iyi yardımcı olabiliriz.
1488 gün önce Panelden eklediğim Sabit Gider her ay otomatik olarak eklensin istiyorum.
sorusunu cevapladı.
sabit giderler için bir tablo oluşturup.
cronjon ile bu tablodaki verileri çekip kayıt işlemi yapabilirsin.
1488 gün önce Prototürk uygulaması
sorusunu cevapladı.
1489 gün önce PHP(Classes) Sınıflarda model listesi yapılabilir mi?
sorusunu cevapladı.
phpde List<T> sınıfı yok bunun yerine array kullanmalısın.
class UserModel {
private int $id;
private String $username;
private String $email;
public function __construct($id, $username, $email){
$this->id = $id;
$this->username = $username;
$this->email = $email;
}
}
class UserList {
protected $users = [];
public function __construct(UserModel ...$list){
$this->users = $list;
}
}
$users = [];
for($i = 0; $i < 10; $i++){
$users[] = new UserModel($i, $i * 2, $i * 10);
}
$userList = new UserList(...$users);
print_r($userList);
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