Severity: 8192
Message: Return type of CI_Session_files_driver::open($save_path, $name) should either be compatible with SessionHandlerInterface::open(string $path, string $name): bool, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice
Filename: drivers/Session_files_driver.php
Line Number: 113
Severity: 8192
Message: Return type of CI_Session_files_driver::close() should either be compatible with SessionHandlerInterface::close(): bool, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice
Filename: drivers/Session_files_driver.php
Line Number: 280
Severity: 8192
Message: Return type of CI_Session_files_driver::read($session_id) should either be compatible with SessionHandlerInterface::read(string $id): string|false, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice
Filename: drivers/Session_files_driver.php
Line Number: 145
Severity: 8192
Message: Return type of CI_Session_files_driver::write($session_id, $session_data) should either be compatible with SessionHandlerInterface::write(string $id, string $data): bool, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice
Filename: drivers/Session_files_driver.php
Line Number: 223
Severity: 8192
Message: Return type of CI_Session_files_driver::destroy($session_id) should either be compatible with SessionHandlerInterface::destroy(string $id): bool, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice
Filename: drivers/Session_files_driver.php
Line Number: 303
Severity: 8192
Message: Return type of CI_Session_files_driver::gc($maxlifetime) should either be compatible with SessionHandlerInterface::gc(int $max_lifetime): int|false, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice
Filename: drivers/Session_files_driver.php
Line Number: 344
Severity: 8192
Message: setcookie(): Passing null to parameter #7 ($httponly) of type bool is deprecated
Filename: core/Input.php
Line Number: 410
Bu makalede PHP'nin array_reverse() fonksiyonunu kullanarak dizide bulunan elemanları ters çevireceğiz. Örnek olarak dizide 1, 2, 3, 4 elemanları olsun, bunu tek fonksiyonla ve hiçbir ekstra değişken kullanmadan 4, 3, 2, 1 şeklinde sıralayacağız.
Syntax
array_reverse(array,preserve)
array: Zorunludur. Ters çevrilecek array.
preserve: İsteğe bağlıdır. true veya false değerleri alabilir. Çevirme esnasında elemanların indeks değerlerinin korunup korunmayacağını belirler. true parametresinde ters çevirme esnasında orijinal dizinin indeks değerleri korunurken false parametresinde korunmaz. Bu parametre sadece nümerik indekslerde çalışır ve varsayılan değer false'dur.
Not: array_reverse() fonksiyonu orijinal diziyi bozmaz.
Örnek 1)
<?php
$dizi = array("1"=>"PES","2"=>"FIFA","3"=>"NBA");
print_r($dizi);
// Çıktı: Array ( [1] => PES [2] => FIFA [3] => NBA )
$dizi1 = array_reverse($dizi);
print_r($dizi1);
// Çıktı: Array ( [0] => NBA [1] => FIFA [2] => PES )
$dizi2 = array_reverse($dizi,false);
print_r($dizi2);
// Çıktı: Array ( [0] => NBA [1] => FIFA [2] => PES )
$dizi3 = array_reverse($dizi,true);
print_r($dizi3);
// Çıktı: Array ( [3] => NBA [2] => FIFA [1] => PES )
?>
Örnek 2)
<?php
$dizi = array("PES","FIFA",array("FM","NBA"));
print_r($dizi);
// Çıktı: Array ( [0] => PES [1] => FIFA [2] => Array ( [0] => FM [1] => NBA ) ))
$dizi1 = array_reverse($dizi);
print_r($dizi1);
// Çıktı: Array ( [0] => Array ( [0] => FM [1] => NBA ) [1] => FIFA [2] => PES )
$dizi2 = array_reverse($dizi,false);
print_r($dizi2);
// Çıktı: Array ( [0] => Array ( [0] => FM [1] => NBA ) [1] => FIFA [2] => PES ) )
$dizi3 = array_reverse($dizi,true);
print_r($dizi3);
// Çıktı: Array ( [2] => Array ( [0] => FM [1] => NBA ) [1] => FIFA [0] => PES )
?>
Örnek 3)
<?php
$dizi = array("a"=>"PES","b"=>"FIFA","c"=>"NBA");
print_r($dizi);
// Çıktı: Array ( [a] => PES [b] => FIFA [c] => NBA )
$dizi1 = array_reverse($dizi);
print_r($dizi1);
// Çıktı: Array ( [c] => NBA [b] => FIFA [a] => PES )
$dizi2 = array_reverse($dizi,false);
print_r($dizi2);
// Çıktı: Array ( [c] => NBA [b] => FIFA [a] => PES )
$dizi3 = array_reverse($dizi,true);
print_r($dizi3);
// Çıktı: Array ( [c] => NBA [b] => FIFA [a] => PES )
// İndeksi nümerik olmayanlar true parametresinden etkilenmez
?>
YORUMLAR