Syntax: string addcslashes ( string $str , string $charlist ) Description: Returns a string with backslashes before characters that are listed in charlist parameter.A list of characters to be escaped. Example 1 <?php $str=”hai…i like india”; echo ‘Input String :’.$str; echo ‘<br/>’; echo ‘Output String (addcslashes($str,”i”)) : ‘.addcslashes($str,’i’); echo ‘<br/>’; ?> OUTPUT Input String :hai…i like india Output […]
Category Archives: PHP
Syntax: string addslashes ( string $str ) Description: Returns a string with backslashes before characters that need to be escaped. These characters are single quote (‘), double quote (“), backslash (\) and NUL Note: Using addcslashes() function we will configure the escaped string. Example 1 <?php $str=”How’re you”; echo ‘Input String :’.$str; echo ‘<br/>’; echo ‘Output String (addslashes($str)) […]
Syntax:array array_splice ( array &$input , int $offset [, int $length = 0 [, mixed $replacement ]] ) Description:Remove a portion of the array and replace it with something else <?php $input = array(“red”, “green”, “blue”, “yellow”); array_splice($input, 2); print_r($input); echo “<br/>”; $input = array(“red”, “green”, “blue”, “yellow”); array_splice($input, 1, -1); print_r($input); ?> OUTPUT Array […]
Syntax: number array_sum ( array $array ) Description: Calculate the sum of values in an array <?php $a = array(2, 4, 6, 8); echo “sum(a) = ” . array_sum($a) . “\n”; $b = array(“a” => 1.2, “b” => 2.3, “c” => 3.4); echo “sum(b) = ” . array_sum($b) . “\n”; ?> OUTPUT sum(a) = 20 […]
Syntax:array array_unique ( array $array [, int $sort_flags = SORT_STRING ] ) Description:Removes duplicate values from an array <?php $input = array(“a” => “green”, “red”, “b” => “green”, “blue”, “red”); $result = array_unique($input); print_r($result); ?> OUTPUT Array ( [a] => green [0] => red [1] => blue )
Syntax: int array_unshift ( array &$array , mixed $var [, mixed $… ] ) Description: Prepend one or more elements to the beginning of an array <?php $queue = array(“orange”, “banana”); array_unshift($queue, “apple”, “raspberry”); print_r($queue); ?> OUTPUT Array ( [0] => apple [1] => raspberry [2] => orange [3] => banana )
Syntax: array array_values ( array $input ) Description: Return all the values of an array <?php $array = array(“size” => “XL”, “color” => “gold”); print_r(array_values($array)); ?> OUTPUT Array ( [0] => XL [1] => gold )
What is PHP? Syntax PHP File How PHP Works? Evolution Of PHP PHP Advantages PHP Comments [gad] What is PHP? PHP stands for “PHP: Hypertext Preprocessor”. Initially it was called “personal home page” PHP is a opensource.PHP costs nothing, it is free to download and use PHP is a scripting language designed for web. PHP […]
Syntax: string bin2hex ( string $str ) Description: Returns an ASCII string containing the hexadecimal representation of str. Note: Using addcslashes() function we can configure the escaped string. Example <?php $str=”good morning”; echo bin2hex($str); ?> OUTPUT 676f6f64206d6f726e696e67
Syntax: chop() — Alias of rtrim() Description: This function is an alias of: rtrim(). Example 1 <?php $str1=”hai “; $str2=”good “; $str3=”morning “; echo $str1.$str2.$str3; echo ‘<br/>’; echo chop($str1).chop($str2).chop($str3); ?> OUTPUT hai good morning haigoodmorning Example 2 <?php $str1=”hai are YOU”; echo chop($str1,’A..Z’); ?> OUTPUT hai are