If you are a PHP developer, these 7 functions must be known for programming.
Function 1 : array_rand
Get a random variable in an array.
$sites = array ("google.com", "yahoo.com", "php.net", "apple.com"); $k = array_rand($sites); echo $sites[$k];
Function 2: strip_tags
Get rid of HTML tags in paragraph. Mostly use in CMS
$message = "<div> This is my bio </div>"; echo strip_tags($message); // "This is my bio"
Function 3: strftime
This function change type of date, time as we want
strftime("%B %d, %Y", time()); // July 28, 2012
Function 4: basename
Get only a file name.
$path = "/some/long/path/to/the/special_file.txt"; $filename1 = basename($path); // special_file.txt $filename2 = basename($path, ".txt"); // special_file
Function 5: list
Re-assign variable in an array
$array = ["Ellery", "Queen"]; list($first-name, $last-name) = $array; echo $first-name; // Ellery echo $last-name; // Queen
Function 6: range
Create an array which contains characters or numbers
range(100, 110); // array(100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 10) range('g', 'l'); // array('g', 'h', 'i', 'j', 'k'. 'l');
Function 7: isset
The most common and useful funciton to check variable existed or not.
$name = "Joe"; isset($name); // return true isset($age); // return false