Search value exist in array or not using php

Search value exist in array or not using php

                In php there is a inbuild function called in_array() which is used to search data is existing or not in array. It returns boolean value i.e "TRUE" if the search value is found in the array, and "FALSE" if the search value is not found.

Syntax :
 bool in_array ( $value, $array_name ,$mode )  

Parameters: The in_array() function accepts three parameters, out of which two are compulsory and other one is optional. All three parameters are described following:
  1. $value: This is the compulsory parameter for in_array () function which contains the searching value. This can be of mixed type i.e, it can be of string type or integer type or any other type. it depends on user that which type of search value wants to find in array.
  2. $array_name: This is a compulsory parameter and it specifies the array in which we want to search.
  3. $mode: This is third one which is an optional parameter and is of boolean type. This parameter specifies the mode in which we want to perform the search. If it is set to TRUE, then the in_array() function searches for the value with the same type of value as specified by $val parameter. The default value of this parameter is FALSE.
Return Value: The in_array() function returns a boolean value i.e, TRUE if the value $val is found in the array otherwise it returns FALSE.

Below programs to illustrate The in_array() function in PHP:

<?php
$marks = array(100, 65, 70, 87);
 
if (in_array("100", $marks))
  {
  echo "found";
  }
else
  {
  echo "not found";
  }
?>

in the program we are searching 100 in array marks weather it exist in array or not. after successfull running when its found the 100 in array then function returns "TRUE" as a "found" string message.

Output:
found




How to import and export mysql database using Command Prompt?

                                  If you have a large database and you want to export which is not exported by phpmyadmin default export option. because it shows some maximum limit or time expired. For that you can try importing and exporting any size database of phpmyadmin using Command prompt.

So command for importing and exporting is below : 

       1. open cmd
       2. set mysql path in cmd

            set path=c:\wamp\bin\mysql\mysql5.6.17\bin

       3. For database export (Backup)
           
           mysqldump -u YourUser -p YourDatabaseName > filename.sql

       4. For database import (Restore): 

            mysql -u YourUser -p YourDatabaseName < filename.sql



you can change your set path command as per your xampp,wampp etc.

Checking format of Email address in excel

Checking email addresses in bulk if the format is correct or not

So in your excel sheet if emails are in A column, go in the B column or other and as per column name put alphabet and row number like B1 cell and copy paste this code: 

=AND(NOT(ISERROR(FIND("@",A1))),NOT(ISERROR(FIND(".",A1))),ISERROR(FIND(" ",A1)))

In formula you can see A2 because A1 is occupied with head column of excel data, After that drag mouse down from B2 it will automatically change the cell row number in formulas or you can copy and paste the code to the other cells. But with respective rownumbers change i.e.

=AND(NOT(ISERROR(FIND("@",A1))),NOT(ISERROR(FIND(".",A1))),ISERROR(FIND(" ",A1)))

 For all the valid e-mails, it will give you ‘TRUE’ and for the invalid ‘FALSE’.

email_validation



Loading gif image for freeze page to process ajax request in jquery

The method is use to show some animated image at time of processing the ajax request with gif image. where we have to use beforeSend object in ajax call for loading gif at time of request processing.

Your ajax function looks like 
$.ajax({
    url: uri,
    cache: false,
    beforeSend: function(){
        // show gif image when request sent
    },
    complete: function(){
        // hide gif image when response receives
    },
    success: function(html){
       // final output hadleling
    }
});
Html Code:
<div class="loading">
  <img src="//image path" class="img-responsive" />
</div> 
Styling CSS Code:
.loading {
  visibility: hidden;
  background-color: rgba(255,255,255,0.7);
  position: absolute;
  z-index: +100 !important;
  width: 100%;
  height:100%;
}

.loading img {
  position: relative;
  top:50%;
  left:50%;
}
Jquery Code: 
$.ajax({
  type:'POST',
  beforeSend: function(){
    $('.loading').css("visibility", "visible");
  },
  url:'/quantityPlus',
  data: {
   'data1':p1,
   'data2':p2,
   'data3':p3},
   success:function(data){
     // data fetch and show on html page
  },
  complete: function(){
    $('.loading').css("visibility", "hidden");
  }
});

}

Check current date falls between two dates function in jquery

         The function is to check date comes between start and end date which should be in "dd/mm/yyyy" format.

function dateCheck(dateFrom,dateTo,dateCheck) {

 var d1 = dateFrom.split("/");
 var d2 = dateTo.split("/");
 var c = dateCheck.split("/");

 var from = new Date(d1[2], parseInt(d1[1])-1, d1[0]);  // -1 because months are from 0 to 11
 var to   = new Date(d2[2], parseInt(d2[1])-1, d2[0]);
 var check = new Date(c[2], parseInt(c[1])-1, c[0]);

    if(check > from && check < to) {
        return true;
    }
    return false;
}
 
 
Calling method

var availability = dateCheck(startTheoryDate,endTheoryDate,currentDate);
 
And finally it returns boolean value weather it is true or false.