Extension:Substring and strlen
|
Substring and Strlen Release status: stable |
|
|---|---|
| Implementation | Parser function |
| Description | This extension adds the ability to get string length and sub strings |
| Author(s) | Brian Malinconico (ArjesTalk) |
| License | No license specified |
| Download | Version 1 code |
|
Check usage (experimental) |
|
[edit] Rational
This code snippet was created to help make templates reverse compatible. The idea is that #substring can be used in combination with the #if function to identify the version of the input string.
[edit] Installation
Copy the code from the download link on the right to your MediaWiki directory extensions directory/SubString/SubString.php
Then at the bottom of your LocalSettings.php file add the following code
require_once($IP . "/extensions/SubString/SubString.php");
[edit] Functions Added
- {{#substring:<string>|<start>|<length>}}
Please see http://us.php.net/manual/en/function.substr.php for more full documentation. In this implementation start defaults to 0. All parameters are sent directly to the php substr function so all valid php input should be valid for this function.
- {{#strlen:<string>}}
Please see http://us.php.net/manual/en/function.strlen.php for more complete documentation. The value passed in <string> is passed directly to the php strlen function. If string is omitted (or blank) it will return a length of 0.
