Saturday, 17 December 2011

array_push() function

array_push() function insert one or more elements at the end of the array.

Following is the example of array_push() function

<?php
$a=array("Dog","Cat");
array_push($a,"Horse","Bird");
print_r($a);
?>

The out put will be

Array ( [0] => Dog [1] => Cat [2] => Horse [3] => Bird ) 




About chr() function

The chr() function returns a character from the specified ASCII value.

Following is a simple example of chr() function

<?php
echo chr(52)."<br />";
echo chr(052)."<br />";
echo chr(0x52)."<br />";
?> 

This code  will give output:

4
*
R




Php chop() function

Php chop() function 

The php chop() function will remove white space from right side of the character.

Following are the example of  chop() function

<?php
$str = "Hello World!\n\n";
echo $str;
echo chop($str);
?>

The Source output will be

 <html>

<body>
Hello World!

Hello World!</body>

</html>

The browser output will be

Hello World! Hello World!









About bin2hex() function

About bin2hex() function

This function can convert a String of ASCII caracters in  hexadecimal value.It can again converted back by using pack() function.

Following is an example of bin2hex() function



<?php
$str = "Hello world!";
echo bin2hex($str) . "<br />";
echo pack("H*",bin2hex($str)) . "<br />";
?>

This will give output:

48656c6c6f20776f726c6421
Hello world! 

addcslashes function

 addcslashes function 

The addcslashes() function returns a string with backslashes in front of the specified characters.


<?php
$str = "Hello, my name is Kai Jim.";
echo $str."<br />";
echo addcslashes($str,'m')."<br />";
echo addcslashes($str,'K')."<br />";
?>