Jump to content

Extension:PhpTags Functions/Functions/Array

From mediawiki.org

Example of usage Array functions

[edit]

As an example, the template that returns a random value from arguments:

<phptag>
array_shift( $argv ); # $argv is array that contains the passed parameters ($argv[0] is always page name, need to remove it here)
shuffle ( $argv ); # shuffles the array
$return = array_pop( $argv ); # get the last value of the array
echo trim( $return ); # the string can contain unnecessary spaces, remove them
</phptag>

Demo

Note Note: information about the PhpTags extension is available in the quick start guide.
Note Note: these functions are similar to the native PHP functions, so you can use PHP documentation