HOW THE QUIZ WORKS:
Clicking the ‘randomize’ button situated above the reference table generates a new table whereby the function descriptions, function syntaxes, and function return values are randomized. The quiz involves matching the function descriptions, function syntaxes, and function return values to the correct function name. Information relating to the randomization of table cells will be displayed for three seconds, before disappearing.
On a desktop computer, table elements are selected by left-clicking the desired table cell and holding the left click in the mouse down position for one second before releasing the left click. The text inside the table cell will turn red to indicate that the one-second mouse left-click has successfully selected a table cell. To then swap the selected table cell with the target table cell, simply repeat the one-second left mouse-click process on the target cell; the table cells will swap position. To de-select a table cell, simply repeat the one-second left mouse-click process on the original table cell.
To select a table element on a touchscreen device (mobile, tablet), simply touch the desired table cell and maintain the touch for one second before removing your finger from the screen. The text inside the table cell will turn red to indicate that the one-second touch has successfully selected a table cell. To then swap the selected table cell with the target table cell, simply repeat the one-second touch process on the target cell; the table cells will swap position. To de-select a table cell, simply repeat the one-second touch process on the original table cell.
Normal touchscreen scrolling behaviour is exhibited by the cells with a light green background; cells without a light green background will not respond to normal touchscreen scrolling. The table is positioned in such a way that the user can also initiate touchscreen scrolling by swiping to the right or left of the table.
When a row consists of the correct function name, function description, function syntax, and function return value, the background colour of the row will change from ‘transparent’ to ‘khaki’; this provides visual feedback that the row is complete.
Once the entire table is complete, a paragraph of feedback will congratulate the user and provide the following information: date and time of quiz commencement; date and time of quiz completion; and the length of time it took the user to complete the quiz.
VIEWPORT OPTIONS:
PURPOSE:
This webpage serves two purposes:
- It provides a reference table for the PHP string functions, with information extracted and condensed from w3schools.com and php.net.
- It enables users to complete a quiz related to the PHP string functions.
USAGE:
For each string function there are four table cells of information: the function name; the function description; the function syntax; and the function return value. There are three layouts available – ‘mobile‘, ‘tablet‘, and ‘desktop‘.
Click the relevant button below to display the PHP string functions reference table, sized appropriately for the desired viewport. A ‘RANDOMIZE‘ button appears above the reference table once the viewport is selected; clicking this button facilitates the commencement of a quiz.
Click the ‘RANDOMIZE‘ button to randomize the functional descriptions, the functional syntaxes, and the functional return information.
| FUNCTION NAME | FUNCTION DESCRIPTION | FUNCTION SYNTAX | FUNCTION RETURN VALUE |
|---|---|---|---|
strrchr()
[Find the last occurrence of a character in a string] |
This function returns the portion of the haystack string which starts at the last [‘reverse’] occurrence of the needle character and continues till the end of haystack. | strrchr(haystack, needle);
[If needle comprises more than one character, only the first one is used; this behaviour differs from |
strrchr(): returns the portion of string, or FALSE if needle is not found. |
strrev()
[Reverse a string] |
This function returns string, reversed. | strrev(string); |
strrev(): returns the reversed string. |
strripos()
[Find the position of the last occurrence of a case-insensitive substring in a string] |
This function finds the numeric position of the last [‘reverse’] case-insensitive occurrence of needle in the haystack string. | strripos(haystack, needle, offset [optional parameter with a default value of 0]);
[needle may be a string of one or more characters; if it is not a string, it is converted to an integer and applied as the ordinal value of a character. If offset is specified and positive, searching will begin this number of characters counted from the beginning of haystack; if negative, searching will begin this number of characters counted from the end of haystack.] |
strripos(): returns the position of where the last [‘reverse’] case-insensitive needle exists relative to haystack [independent of offset]. String positions start at 0 and not 1. Returns FALSE if needle was not found. |
strrpos()
[Find the position of the last occurrence of a case-sensitive substring in a string] |
This function finds the numeric position of the last [‘reverse’] case-sensitive occurrence of needle in the haystack string. | strrpos(haystack, needle, offset [optional parameter with a default value of 0]);
[needle may be a string of one or more characters; if it is not a string, it is converted to an integer and applied as the ordinal value of a character. If offset is specified and positive, searching will begin this number of characters counted from the beginning of haystack; if negative, searching will begin this number of characters counted from the end of haystack.] |
strrpos(): returns the position of where the last [‘reverse’] case-sensitive needle exists relative to haystack [independent of offset]. String positions start at 0 and not 1. Returns FALSE if needle was not found. |
strspn()
[Finds the length of the initial segment of a string consisting entirely of characters contained within a given mask] |
This function finds the length [‘span’] of the initial segment of subject string consisting entirely of characters contained within a given mask. If start and length are omitted, then all of subject will be examined. If start and length are included, then the effect will be the same as calling strspn(substr($subject, $start, $length), $mask). |
strspn(subject, mask, start [optional parameter], length [optional parameter]);
[If start is specified and is positive, |
strspn(): returns the length [‘span’] of the initial segment of subject string which consists entirely of characters in mask. When a start parameter is set, length is counted from this starting position – not from the beginning of subject. |
strtok()
[Tokenize string] |
This function splits string into smaller strings [tokens], with each of these smaller strings being delimited by any character from token. Only the first call to strtok() uses the string argument; each subsequent call only needs the token to use, since it keeps track of where it is in the current string. To start again – or to tokenize a new string – simply call strtok() with the string argument again to initialize it. Multiple tokens are permitted in the token parameter; the string will be tokenized when any one of the characters in the argument is found. |
First function call:strtok(string, token);Subsequent function calls: strtok(token); |
strtok(): returns a string token. |
strtolower()
[Make a string lowercase] |
This function returns string with all alphabetic characters converted to lowercase. ‘Alphabetic’ is determined by the current locale: in the default C locale, characters such as umlaut-A – for example – will not be converted. | strtolower(string); |
strtolower(): returns string converted to lowercase. |
strtoupper()
[Make a string uppercase] |
This function returns string with all alphabetic characters converted to uppercase. ‘Alphabetic’ is determined by the current locale: in the default C locale, characters such as umlaut-A – for example – will not be converted. | strtoupper(string); |
strtoupper(): returns string converted to uppercase. |
strtr()
[Translate characters or replace substrings] |
If passed three arguments, this function returns a copy of string where all occurrences of each [single-byte] character in from have been translated to the corresponding character in to, videlicet– every occurrence of $from[$n] has been replaced with $to[$n], where n is a valid offset in both arguments. If from and to have different lengths, the extra characters in the longer of the two will be ignored; the length of string will be the same as the return value’s. |
With three arguments:strtr(string, from, to);With two arguments: strtr(string, replace_array);
[If given two arguments, the replace_array should be of the form |
strtr(): returns the translated string on success. If replace_array contains a key which is an empty string, FALSE is returned. If string is not scalar it is not typecasted into a string; instead a warning is raised and NULL is returned. |
substr_compare()
[Binary safe comparison of two strings from an offset, up to length characters] |
This function compares main_string – from position offset – with second_string [‘substring’] [up to length characters]. | substr_compare(main_string, second_string, offset, length [optional parameter, with a default value equal to the largest of *length of second_string*/*main_string – offset], case_insensitivity [optional parameter with a default value of FALSE]);
[offset specifies the position at which to start counting. If negative, the comparison begins at offset characters from the end of the string.] |
substr_compare(): returns <0 if main_string from position offset is less than second_string; returns >0 if main_string from position offset is greater than second_string; returns 0 if main_string from position offset is equal to second_string. A WARNING is printed and FALSE is returned if offset is equal to or greater than the length of main_string, or the length is set and less than 1 in PHP versions prior to 5.5.11. |

