How to reverse an array in Javascript?

 

Method 1

<script>

    let numbers_array = [11, 22, 33, 54, 55];
     
    console.log("Original Array: ");
    console.log(numbers_array);
     
    numbers_array.reverse();
     
    console.log("Reversed Array: ");
    console.log(numbers_array);
</script>

    Output:

Original Array: 
[ 11, 22, 33, 44, 55 ]
Reversed Array: 
[ 55, 44, 33, 22, 11 ]
Method 2
 let original_array = [11, 22, 33, 44];
 
 let reversed_array = [];
 
 console.log("Original Array: ");
 console.log(original_array);
 
  for (let i = original_array.length - 1; i >= 0; i--) {
        reversed_array.push(original_array[i]);
  }
 
  console.log("Reversed Array: ");
  console.log(reversed_array);

    Output:

Original Array: 
[ 11, 22, 33, 44, 55 ]
Reversed Array: 
[ 55, 44, 33, 22, 11 ]
Method 3
let original_array = [11, 22, 33, 44, 55, 66];
 
let reversed_array = [];
 
console.log("Original Array: ");
console.log(original_array);
 
original_array.forEach((element) => {
      reversed_array.unshift(element);
});
 
console.log("Reversed Array: ");
console.log(reversed_array);
Original Array: 
[ 11, 22, 33, 44, 55,66 ]
Reversed Array: 
[66, 55, 44, 33, 22, 11 ]

WHAT IS AN HTML ELEMENT ?

 An HTML elements is defined by a star tag , some content , and an end tag .

 < tagname > content goes here ..... < /tagname >

The HTML elements is everything from the start tag to the end tag : 

 < h1 > first heading < h 1>

 < p > my first paragraph < /p >

START  TAG         ELEMENT CONTENT       END TAG

< h1 >                        my first heading                     </h1>

<p>                              my first paragraph                 </p>

<br>                            none                                        none

                         


                 

What Is HTML?

 HTML is Hyper Text Markup Language.

HTML tag,

HTML,

Body,

Title

How to check every two minute in javascript Function Using set Interval

 

setInterval(function(){
alert("Kindly save your details to avoid data lose");
}, 2000);

How to check DOB less then 18 in Javascript


Javascript Function :


 var currDate =01/03/2023

var date_birth = 04/03/1994

function isLessThan18(currDate, date_birth)

{

var currday=parseInt(currDate.substring(0,2),10);

var currMnth=parseInt(currDate.substring(3,5),10);

var currYear=parseInt(currDate.substring(6,10),10);

var dobDay=parseInt(date_birth.substring(0,2),10);

var dobMon=parseInt(date_birth.substring(3,5),10);

var dobYear=parseInt(date_birth.substring(6,10),10);

if(currYear-dobYear<18)

{

return true;

}

else if(currYear-dobYear>18)

{

return false;

}

else if(currYear-dobYear==18)

{

if(currMnth>dobMon)

{

return false;

}

else if(currMnth<dobMon)

{

return true;

}

else if(currMnth==dobMon)

{

if(currday<dobDay)

{

return true;

}

else if(currday>=dobDay)

{

return false;

}

}

}

}




How to clear session in PHP Simple way

 You can clear _SESSION 


<?php

        session_start(); 

          session_destroy();

        $_SESSION = [];

echo '<h1>You have been successfully remove session</h1>';

?>

Can't upload file using PHP on Ubuntu | Solved


Change permission to UPLOAD file into upload folder on UBUNTU

Read + Write

sudo chmod -R a+rw images/

Read + Write + Execute

 sudo chmod -R a+rwx upload/

Example Like this:

bitnahuhi@ip-000-00-00-00:~/htdocs/admin$ sudo chmod -R a+rwx images/

 <?php 


/<?php

  $name = $_FILES['file']['name'];
  $temp = $_FILES['file']['tmp_name'];

  if(move_uploaded_file($temp,"upload/".$name)){
   echo "Your file was uploaded";
}
 else
{ 
 echo "Your file cound't upload";
}

?>

?> 


Session in PHP: Creating, Destroying, and Working With Session in PHP | Demo




#session php

How to Start a PHP Session?

You can start a session in PHP by using the session_start() function. This function will, by default, first check for an existing session. If a session already exists, it will do nothing, but it will create one if there’s no pre-existing session available


<?php

   session_start();

   if( isset( $_SESSION['counter'] ) ) {

      $_SESSION['counter'] += 1;

   }else {

      $_SESSION['counter'] = 1;

   }

   $count= "This page is visited ".  $_SESSION['counter'];

   $count.= " time during this session.";

?>

<html>

   <head>

      <title>Starting a PHP session</title>

   </head>

   <body>

      <?php  echo ( $count); ?>

   </body>

</html>


How to Destroy a Session in PHP?

Example: Using unset() to Destroy a Session Variable

<?php

    unset($_SESSION[‘counter’]);

?>

How to send Email Invoice using | MPDF

 <?php

 require $_SERVER['DOCUMENT_ROOT'].'/pdf/phpmailer/class.phpmailer.php';

require  $_SERVER['DOCUMENT_ROOT'].'/vendor/autoload.php';

$to = "vijaychauhanssn@gmail.com"; 

$from = "vijaychauhanssn@gmail.com"; 

$subject = "sunject here"; 

$message = "<p>Msg here</p>";

$stylesheet = file_get_contents($_SERVER['DOCUMENT_ROOT'].'/assets/css/pdf.css');

$html = '<div id="printablearea">

<div class="container1" >

    body content here

    </div>

</div>';



$mpdf = new \Mpdf\Mpdf(['tempDir' => sys_get_temp_dir().DIRECTORY_SEPARATOR.'mpdf','default_font' => 'Arial', 'format' => 'A4']);

$mpdf->autoScriptToLang = true;

$mpdf->autoLangToFont = true;

$mpdf->WriteHTML($stylesheet, 1);

$mpdf->WriteHTML($html);


//call watermark content aand image

//$mpdf->SetWatermarkText('rajsahumahasabha.com');

$mpdf->showWatermarkText = true;

$mpdf->watermarkTextAlpha = 0.1;

//$mpdf->Output("invoice.pdf", 'F');


//$mpdf->Output();

// a random hash will be necessary to send mixed content

$separator = md5(time());


// carriage return type (we use a PHP end of line constant)

$eol = PHP_EOL;


// attachment name

$filename = "invoice.pdf";


// encode data (puts attachment in proper format)

$pdfdoc = $mpdf->Output("", "S");

//$pdf->Output();

$attachment = chunk_split(base64_encode($pdfdoc));


// main header

$headers  = "From: ".$from.$eol;

$headers .= "MIME-Version: 1.0".$eol; 

$headers .= "Content-Type: multipart/mixed; boundary=\"".$separator."\"";


// no more headers after this, we start the body! //


$body = "--".$separator.$eol;

$body .= "Content-Transfer-Encoding: 7bit".$eol.$eol;

//$body .= "This is a MIME encoded message.".$eol;


// message

$body .= "--".$separator.$eol;

$body .= "Content-Type: text/html; charset=\"iso-8859-1\"".$eol;

$body .= "Content-Transfer-Encoding: 8bit".$eol.$eol;

$body .= $message.$eol;


// attachment

$body .= "--".$separator.$eol;

$body .= "Content-Type: application/octet-stream; name=\"".$filename."\"".$eol; 

$body .= "Content-Transfer-Encoding: base64".$eol;

$body .= "Content-Disposition: attachment".$eol.$eol;

$body .= $attachment.$eol;


$body .= "--".$separator."--";

// send message

mail($to, $subject, $body, $headers);


exit;

?>  

SQL Server — Core Concepts with examples

  Data Definition Language (DDL) : CREATE , ALTER , DROP (tables, views, procedures, triggers). Data Manipulation Language (DML) : SELECT ,...

Best for you