PHP 5
-
strpos
strpos (PHP 4, PHP 5) strpos — Find position of first occurrence of a string Description int strpos ( string $haystack , mixed $needle [, int $offset= 0 ] ) Returns the numeric position of the first occurrence of needle in the haystack string. Unlike the strrpos() before PHP 5, this function can take a… Continue reading
-
ucfirst
ucfirst :: (PHP 4, PHP 5) ucfirst — Make a string’s first character uppercase Description string ucfirst ( string $str ) Returns a string with the first character of str capitalized, if that character is alphabetic. Note that ‘alphabetic’ is determined… Continue reading
-
end
end (PHP 4, PHP 5) end — Set the internal pointer of an array to its last element Description mixed end ( array &$array ) end() advances array’s internal pointer to the last element, and returns its value. $fruits = array(’apple’, ‘banana’, ‘cranberry’); echo end($fruits); // cranberry Continue reading
-
empty
empty (PHP 4, PHP 5) empty — Determine whether a variable is empty Description bool empty ( mixed $var ) Determine whether a variable is considered to be empty. $var = 0; // Evaluates to true because $var is empty if (empty($var)) { echo ‘$var is either 0, empty, or not set at all’; }… Continue reading
-
count_chars
count_chars (PHP 4, PHP 5) count_chars — Return information about characters used in a string Description mixed count_chars ( string $string [, int $mode] ) Counts the number of occurrences of every byte-value (0..255) in string and returns it in various ways. $data = “Two Ts and one F.”; foreach (count_chars($data, 1) as $i =>… Continue reading
-
chop
chop (PHP 4, PHP 5) chop — Alias of rtrim() Description This function is an alias of: rtrim(). Notes Note: chop() is different than the Perl chop() function, which removes the last character in the string. Continue reading
-
rtrim
rtrim (PHP 4, PHP 5) rtrim — Strip whitespace (or other characters) from the end of a string Description string rtrim ( string $str [, string $charlist] ) This function returns a string with whitespace stripped from the end of str. $text = “ttThese are a few words … “; $binary = “x09Example stringx0A”; $hello… Continue reading
-
ltrim
ltrim (PHP 4, PHP 5) ltrim — Strip whitespace (or other characters) from the beginning of a string Description string ltrim ( string $str [, string $charlist] ) Strip whitespace (or other characters) from the beginning of a string. $text = “ttThese are a few words … “; $binary = “x09Example stringx0A”; $hello = “Hello… Continue reading
-
array_sum
array_sum (PHP 4 >= 4.0.4, PHP 5) array_sum — Calculate the sum of values in an array Description number array_sum ( array $array ) array_sum() returns the sum of values in an array as an integer or float. $a = array(2, 4, 6, 8); echo “sum(a) = ” . array_sum($a) . “n”; $b = array(“a”… Continue reading
-
array_slice
array_slice (PHP 4, PHP 5) array_slice — Extract a slice of the array Description array array_slice ( array $array, int $offset [, int $length [, bool $preserve_keys]] ) array_slice() returns the sequence of elements from the array array as specified by the offset and length parameters. If offset is non-negative, the sequence will start at… Continue reading
-
chown
chown (PHP 4, PHP 5) chown — Changes file owner Description bool chown ( string $filename, mixed $user ) Attempts to change the owner of the file filename to user user. Only the superuser may change the owner of a file. Notes Note: This function will not work on remote files as the file to… Continue reading
-
htmlspecialchars_decode
htmlspecialchars_decode (PHP 5 >= 5.1.0) htmlspecialchars_decode — Convert special HTML entities back to characters Description string htmlspecialchars_decode ( string $string [, int $quote_style= ENT_COMPAT ] ) This function is the opposite of htmlspecialchars(). It converts special HTML entities back to characters. The converted entities are: &, " (when ENT_NOQUOTES is not set), ' (when ENT_QUOTES… Continue reading
-
strtolower
strtolower (PHP 4, PHP 5) strtolower — Make a string lowercase Description string strtolower ( string $str ) Returns string with all alphabetic characters converted to lowercase. Note that ‘alphabetic’ is determined by the current locale. This means that in i.e. the default “C” locale, characters such as umlaut-A (Ä) will not be converted. Continue reading
-
str_split
str_split (PHP 5) str_split — Convert a string to an array Description array str_split ( string $string [, int $split_length= 1 ] ) Converts a string to an array. Parameters string The input string. split_length Maximum length of the chunk. Continue reading
-
lcfirst
lcfirst (PHP 5 >= 5.3.0) lcfirst — Make a string’s first character lowercase Description string lcfirst ( string $str ) Returns a string with the first character of str , lowercased if that character is alphabetic. Note that ‘alphabetic’ is determined by the current locale. For instance, in the default “C” locale characters such as… Continue reading
-
html_entity_decode
html_entity_decode (PHP 4 >= 4.3.0, PHP 5) html_entity_decode — Convert all HTML entities to their applicable characters Description string html_entity_decode ( string $string [, int $quote_style= ENT_COMPAT [, string $charset ]] ) html_entity_decode() is the opposite of htmlentities() in that it converts all HTML entities to their applicable characters from string . Continue reading
-
explode
explode (PHP 4, PHP 5) explode — Split a string by string Description array explode ( string $delimiter , string $string [, int $limit ] ) Returns an array of strings, each of which is a substring of string formed by splitting it on boundaries formed by the string delimiter . Continue reading
-
addcslashes
addcslashes (PHP 4, PHP 5) addcslashes — Quote string with slashes in a C style Description string addcslashes ( string $str , string $charlist ) Returns a string with backslashes before characters that are listed in charlist parameter. Continue reading
addcslashes, array, array_splice, black, blue, count_chars, example, foreach, function, green, input, maroon, offset, output, PHP 4, PHP 5, Php function, portion, purple -
stristr
stristr (PHP 4, PHP 5) stristr — Case-insensitive strstr() Description string stristr ( string $haystack , mixed $needle [, bool $before_needle= false ] ) Returns all of haystack from the first occurrence of needle to the end. Continue reading
-
array_splice
array_splice (PHP 4, PHP 5) array_splice — Remove a portion of the array and replace it with something else Description array array_splice ( array &$input, int $offset [, int $length [, array $replacement]] ) array_splice() removes the elements designated by offset and length from the input array, and replaces them with the elements of the… Continue reading
-
chroot
chroot (PHP 4 >= 4.0.5, PHP 5) chroot — Change the root directory Description bool chroot ( string $directory ) Changes the root directory of the current process to directory. This function is only available if your system supports it and you’re using the CLI, CGI or Embed SAPI. Also, this function requires root privileges. Continue reading
CGI, chroot, CLI, directory, function, php, PHP 5, Php function, Privileges, process, root, root privileges, SAPI -
file
file (PHP 4, PHP 5) file — Reads entire file into an array Description array file ( string $filename [, int $flags [, resource $context]] ) Reads an entire file into an array. Note: You can use file_get_contents() to return the contents of a file as a string. // Get a file into an array.… Continue reading
-
fopen
fopen (PHP 4, PHP 5) fopen — Opens file or URL Description resource fopen ( string $filename, string $mode [, bool $use_include_path [, resource $context]] ) fopen() binds a named resource, specified by filename, to a stream. $handle = fopen(“c:abc.txt”, “r”); Table 93. A list of possible modes for fopen() using mode mode Description ‘r’… Continue reading
-
copy
copy (PHP 4, PHP 5) copy — Copies file Description bool copy ( string $source, string $dest [, resource $context] ) Makes a copy of the file source to dest. If you wish to move a file, use the rename() function. $file = ‘example.txt’; $newfile = ‘example.txt.bak’; if (!copy($file, $newfile)) { echo “failed to copy… Continue reading
-
chunk_split
chunk_split (PHP 4, PHP 5) chunk_split — Split a string into smaller chunks Description string chunk_split ( string $body [, int $chunklen [, string $end]] ) Can be used to split a string into smaller chunks which is useful for e.g. converting base64_encode() output to match RFC 2045 semantics. It inserts end every chunklen characters. Continue reading
-
array_reduce
array_reduce (PHP 4 >= 4.0.5, PHP 5) array_reduce — Iteratively reduce the array to a single value using a callback function Description mixed array_reduce ( array $input, callback $function [, int $initial] ) array_reduce() applies iteratively the function function to the elements of the array input, so as to reduce the array to a single… Continue reading
-
array_rand
array_rand (PHP 4, PHP 5) array_rand — Pick one or more random entries out of an array Description mixed array_rand ( array $input [, int $num_req] ) array_rand() is rather useful when you want to pick one or more random entries out of an array. It takes an input array and an optional argument num_req… Continue reading
-
array_pop
array_pop (PHP 4, PHP 5) array_pop — Pop the element off the end of array Description mixed array_pop ( array &$array ) array_pop() pops and returns the last value of the array, shortening the array by one element. If array is empty (or is not an array), NULL will be returned. Note: This function will… Continue reading
-
array_pad
array_pad (PHP 4, PHP 5) array_pad — Pad array to the specified length with a value Description array array_pad ( array $input, int $pad_size, mixed $pad_value ) array_pad() returns a copy of the input padded to size specified by pad_size with value pad_value. If pad_size is positive then the array is padded on the right,… Continue reading
-
strrev (PHP 4, PHP 5)
strrev (PHP 4, PHP 5) strrev — Reverse a string (like just mirror image). Description string strrev ( string $string ) Returns string, reversed. echo strrev(“Praful Kumar!”); // outputs “!ramuK lufarP” Continue reading
-
String functions in PHP
1. str_replace (PHP 4, PHP 5) str_replace — Replace all occurrences of the search string with the replacement string Description mixed str_replace ( mixed $search, mixed $replace, mixed $subject [, int &$count] ) This function returns a string or an array with all occurrences of search in subject replaced with the given replace value. //… Continue reading