number_format — Format a number with grouped thousands
Saturday, 31 March 2012
Q: What is nl2b.
nl2br — Inserts HTML line breaks before all newlines in a string
<?php
echo nl2br("Welcome\r\nThis is my HTML document", false);
?>
echo nl2br("Welcome\r\nThis is my HTML document", false);
?>
Welcome<br>
This is my HTML document
Q: How can encrypt and decript in mysql .
AES_DECRYPT() Decrypt using AES
AES_ENCRYPT() Encrypt using AES
AES_ENCRYPT() Encrypt using AES
$query = "insert into member (spid,uname,pss) values ('$xyz','$username',aes_encrypt('$password','password'))";
$query = "select uname,aes_decrypt(pss,'password') as password from member where spid='$xyz'";
Q:How can get ip address using php
$ip=@$REMOTE_ADDR;
echo "<b>IP Address= $ip</b>";
echo "<b>IP Address= $ip</b>";
IP address= 1.23.174.67
$ip=$_SERVER['REMOTE_ADDR'];
Q: How can get days between two date in php
$days = (strtotime("2005-11-20") - strtotime(date("Y-m-d"))) / (60 * 60 * 24);
Q: How can find out unique number array.
array_unique — Removes duplicate values from an array.
<?php
$input = array("a" => "green", "red", "b" => "green", "blue", "red");
$result = array_unique($input);
print_r($result);
?>
$input = array("a" => "green", "red", "b" => "green", "blue", "red");
$result = array_unique($input);
print_r($result);
?>
Q: How can reverse strings in php
strrev — Reverse a string
<?php
echo strrev("Hello world!"); // outputs "!dlrow olleH"
?>
echo strrev("Hello world!"); // outputs "!dlrow olleH"
?>
Monday, 19 March 2012
Q: how can shorting array in php?
Q: how can shorting array .
Or
Q: What is shorting array
sort — Sort an array
<?php
$fruits = array("lemon", "orange", "banana", "apple");
sort($fruits);
foreach ($fruits as $key => $val) {
echo "fruits[" . $key . "] = " . $val . "\n";
}
?>
$fruits = array("lemon", "orange", "banana", "apple");
sort($fruits);
foreach ($fruits as $key => $val) {
echo "fruits[" . $key . "] = " . $val . "\n";
}
?>
fruits[0] = apple
fruits[1] = banana
fruits[2] = lemon
fruits[3] = orange
arsort — Sort an array in reverse order and maintain index association
<?php
$fruits = array("d" => "lemon", "a" => "orange", "b" => "banana", "c" => "apple");
arsort($fruits);
foreach ($fruits as $key => $val) {
echo "$key = $val\n";
}
?>
$fruits = array("d" => "lemon", "a" => "orange", "b" => "banana", "c" => "apple");
arsort($fruits);
foreach ($fruits as $key => $val) {
echo "$key = $val\n";
}
?>
a = orange
d = lemon
b = banana
c = apple
next — Advance the internal array pointer of an array
<?php
$transport = array('foot', 'bike', 'car', 'plane');
$mode = current($transport); // $mode = 'foot';
$mode = next($transport); // $mode = 'bike';
$mode = next($transport); // $mode = 'car';
$mode = prev($transport); // $mode = 'bike';
$mode = end($transport); // $mode = 'plane';
?>
$transport = array('foot', 'bike', 'car', 'plane');
$mode = current($transport); // $mode = 'foot';
$mode = next($transport); // $mode = 'bike';
$mode = next($transport); // $mode = 'car';
$mode = prev($transport); // $mode = 'bike';
$mode = end($transport); // $mode = 'plane';
?>
Q: what is func_num_args() and func_get_arg() in php ?
func_num_args — Returns the number of arguments passed to the function.
<?phpfunction foo(){ $numargs = func_num_args(); echo "Number of arguments: $numargs\n";}foo(1, 2, 3); ?>
Subscribe to:
Posts (Atom)