How to insert new key value pair inside a multidimensional associative array in PHP

To insert new key value pair inside a multidimensional associative array in PHP
Here am going to explain in details
We have a sample array we need to add Version4 and its value inside the array

$list_array = array( 
            0 => array (
               "Version1" => 2016,
               "Version2" => 2017,	
               "Version3" => 2018
            ),
            
            1 => array (
               "Version1" => 2016,
               "Version2" => 2017,	
               "Version3" => 2018
            )
         );

Here am using for each mange that

 foreach($list_array as $key=>$valuue)
	 {
	  $list[$key]=$listvalue;
	  $list[$key]['Version4']= 2019;
	 }
       print_r($list);

Result

 
array( 
            0 => array (
               "Version1" => 2016,
               "Version2" => 2017,	
               "Version3" => 2018,
               "Version4" => 2019
          
              
            ),
            
            1 => array (
               "Version1" => 2016,
               "Version2" => 2017,	
               "Version3" => 2018,
               "Version4" => 2019
            )
         );

Sample php code for sending OTP

Most of the user oriented website are slowly changing from email and password based login to OTP based login.so for a developer it is necessary to know how to create on OTP based login, here am going to share you Sample PHP code for sending OTP.

First you have to Register with any of the SMS Service providers ,here am using mysmsmantra.Here we are achieving with the help of CURL in PHP,this is the URL API from mysmsmantra for sedning OTP http://bulksms.mysmsmantra.com/WebSMS/SMSAPI.jsp?username=YOUR_USERNAME&password=YOUR_PASSWORD&sendername=rahaul&mobileno=*******&message=your OTP
where YOUR_USERNAME and YOUR_PASSWORD are respectively user name and password from mysmsmantra.

$otp=rand(100000, 999999);
$msg="Dear Customer, One Time Password for activating your account is :".$otp;
$message=urlencode($msg); 
$messageUrl="http://bulksms.mysmsmantra.com/WebSMS/SMSAPI.jsp?username=YOUR_USERNAME&password=YOUR_PASSWORD&sendername=rahaul&mobileno=*******&message=".$message; 
//YOUR_USERNAME and YOUR_PASSWORD are respectively from mysmsmantra
$ch = curl_init($messageUrl); 
$fp = fopen("message.txt", "w+"); 
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); 
curl_setopt($ch, CURLOPT_FILE, $fp); 
curl_setopt($ch, CURLOPT_HEADER, 0); 
curl_exec($ch); curl_close($ch); 

fclose($fp);

PHP code to Send HTML Mail templates

PHP provide easy method to send HTML template inside mail function.Here am going to elaborate that with you

Here is the code

First you have to specify Content-type:text/html;charset=UTF-8 in header

see

$headers = "MIME-Version: 1.0" . "\r\n";
$headers .= "Content-type:text/html;charset=UTF-8" . "\r\n";

Subject specify mail subject

see

$subject="Tutorialshore: HAPPY TO SHARE OUR NEW LOCATION WITH YOU";

Message specify HTML mail messgae

see

$message = "<html><body><h1>OUR NEW LOCATION</h1><p>Welcome you</p><p><img alt="Happy New Year 2018 Wishes" src="https://www.tutorialshore.com/wp-content/uploads/2018/08/google-map-1-1024x576.png" /></p></body></html>";

Here is the full code

 $subject="Tutorialshore: HAPPY TO SHARE OUR NEW LOCATION WITH YOU";
$message = "<html><body><h1>OUR NEW LOCATION</h1><p>Welcome you</p><p><img alt="Happy New Year 2018 Wishes" src="https://www.tutorialshore.com/wp-content/uploads/2018/08/google-map-1-1024x576.png" /></p></body></html>";
$headers = "MIME-Version: 1.0" . "\r\n";
$headers .= "Content-type:text/html;charset=UTF-8" . "\r\n";
// More headers
$headers .= $this->from_mail. "\r\n";
 
mail("[email protected]",$subject,$message,$headers);

Output Mail templates

OUR NEW LOCATION

Welcome you

Happy New Year 2018 Wishes