Key value pairs in PHP known as associative arrays. Example is given below where we are adding more items to the previously initialized associative array. <?php //Creating Associative Array. $array = array( "Robert" => "USA", "Peter" => "UK", ); echo "Before Addition Array Length: ". count($array)."<br />"; //Adding more items to Associative Array; $array["Mike"] =
To break for loop in PHP when a certain condition is met, we make use of break statement. <?php for ($i = 0; $i <= 10; $i++) { if($i == 5) { echo "The number is $i. <br>"; break; } } ?>
To redirect to another website in PHP, we make use of header function. Sample code is given below: <?php header('Location: http://www.google.com/'); exit; ?>
To get array length in PHP, we make use of Count function. Sample code is given below. <?php $array = array("Robert", "Rony", "Peter", "Sam"); echo count($array); ?>
Sample code is given below, where we are adding 1 year to the current date. <?php $today = date("Y-m-d"); $oneyear = date('Y-m-d', strtotime($today. ' + 1 year')); echo $oneyear; ?>