Sunday, 27 July 2014

md5() in php

md5() Function:

                          md5() function is use to md5 hash of the string. The function is use for the security purpose.

Syantax:

         md5(string,raw);raw(optional): its value may b TRUE or FALSE it by default false if its value is TRUE then it mean 16 character binary value if its value is FALSE its mean 32 character hex value

Example:

<?php
$str=”Hello”;
echo md5($str);
?>

Output:

          8b1a9953c4611296a827abf8c47804d7


echo/print function in php video



2-echo/print function in php



Saturday, 26 July 2014

ltrim() function in php

ltrim() Function :

                               ltrim() function which remove the specific character from the left side the string or remove the white spaces from the left side of the string.

Syntax:

          ltrim(string, specific character);     specific character is optional if we don’t use it then it remove the white space from the left side.

Example:

<?php$str= “hello php”.”<br/>”;
$str2= “        hello php”;
echo  ltrim($str,”hello”);echo ltrim($str);?>

Output:

           hello php
           hello php
the other function is rtrim and trim. rtrim is use to remove the spaces from the right side or specific character from right side and trim function is use to remove the space from both side or remove the specific character from both side of the string.


implode() Function in php

implode() Function:

                            implode() function which return the string from array elements .

syntax:

             implode(separator,array)

example:

<?php$arr=array(“hello”,”I”,”am”,”using”,”programminglogic”);echo  implode(“ “,$arr).”<br/>”;echo  implode(“-“,$arr); 
?>

Output:      

           hello I am using programminglogic    
           hello-I-am-using-programminglogic


bin2hex() Function in php:

bin2hex() Function:

                            bin2hex()  function is use to convert the ascii character value of a string into hexadecimal value. The string can b reconvert by using packk() function

syntax:

          bin2hex(string)

Example:

<?php
$str= “hello I am using programminglogic”;
echo bin2hex($str);?>

Output:
68656c6c6f204920616d207573696e672070726f6772616d6d696e676c6f676963


explode() function in php

Explode() Function():

                            explode() function is use to break the string into array. For example we have a string “hello I am using programminglogic” we can break the string from space it mean “hello” is in zero index of array “I” is in first index and so on

Syntax:

             explode(separate , string, limitation)

separate: give the separator where u want to break the string it may b space or comma etc

limitation: give the maximum limit of string element where you want to break the string it should be greater then zero.(optional)

Example:

<?php

$str= “hello I am using programminglogic”;

Print_r(explode(' ',$str,0)); //I use separator space

Print_r(explode(' ',$str,2));

Print_r(explode(' ',$str));     //if I don’t use the limitation the whole string will be break.

?>

Output:

          Array ( [0] => hello I am using programminglogic  ) 

          Array ( [0] => hello  [1] => I am using programminglogic  )

          Array ( [0] => hello  [1] => I [2] => am [3] => using [4] => programminglogic  )