Monday, September 4th, 2006 (updated 5 Oct ’10)

Documentation for PHPStringFun v1.2.1

 
  • Version
    1.2.1
  • Type
    Plugins
  • More info
  • Elsewhere
    "EE Forums":http://expressionengine.com/forums/viewthread/37805/ "Devot-ee":http://devot-ee.com/add-ons/plugins/phpstringfun/
  • Download
h2. Compatibility The plugin works on both EE v1.x and v2.x. h2. Installation h4. EE v1.x Place the _pi.phpstringfun.php_ file in the _/system/plugins_ directory. h4. EE v2.x Create in the _/system/expressionengine/third_party_ directory a directory _/phpstringfun_, then place the _pi.phpstringfun.php_ file in there. h2. Parameters h4. array_index If the function's result is an array, such as explode, the array_index parameter allows you to set which result from the array to produce. Also see the separator parameter. h4. function (required) PHPStringFun requires the "function" parameter to be a PHP string function. Some functions cannot be used. These are fprintf() and implode(). Those that can be used are: addcslashes, bin2hex, chop, chr, chunk_split, convert_cyr_string, convert_uudecode, convert_uuencode, count_chars, crc32, crypt, echo, explode, get_html_translation_table, hebrev, hebrevc, html_entity_decode, htmlentities, htmlspecialchars_decode, htmlspecialchars, join, levenshtein, localeconv, ltrim, md5_file, md5, metaphone, money_format, nl_langinfo, nl2br, number_format, ord, parse_str, print, printf, quoted_printable_decode, quotemeta, rtrim, setlocale, sha1_file, sha1, similar_text, soundex, sprintf, sscanf, str_ireplace, str_pad, str_repeat, str_replace, str_rot13, str_shuffle, str_split, str_word_count, strcasecmp, strchr, strcmp, strcoll, strcspn, strip_tags, stripcslashes, stripos, stripslashes, stristr, strlen, strnatcasecmp, strnatcmp, strncasecmp, strncmp, strpbrk, strpos, strrchr, strrev, strripos, strrpos, strspn, strstr, strtok, strtolower, strtoupper, strtr, substr_compare, substr_count, substr_replace, substr, trim, ucfirst, ucwords, urlencode, vfprintf, vprintf, vsprintf, wordwrap. h4. reverse Some functions work better if the order that the plugin accepts parameters is reversed. For instance, the explode function works better when reverse is set to "yes", allowing the delimiter to be set as a parameter and the string to come within the body of the plugin. h4. par1, part2, par3, par4 and par5 What comes between the tags is essentially the initial parameter. Phpstringfun accepts up to five additional parameters (par1, part2, par3, par4 and par5) needed by the chosen PHP string function. These parameters must be in sequence, so that if there's a par2 there must also be a par1. To know how many parameters the function takes, see its PHP documentation. h4. separator If the output of the plugin is an array, the separator parameter lets you set which character separates the items in the array. Also see the array_index parameter. h2. Examples For example:
{exp:phpstringfun function="rtrim" par1="st"}test{/exp:phpstringfun}
would return "te".
{exp:phpstringfun function="explode" par1="," separator="|" reverse="y"}one,and.two,and,three{/exp:phpstringfun}
would return "one|and.two|and|three|" while
{exp:phpstringfun function="explode" par1="," array_index="2" reverse="y"}one,and.two,and,three{/exp:phpstringfun}
would return "and". h2. Thanks Thanks to Derek Jones for making me clean up the (rather sparse) code and Ingmar Greil and Mark Bowen for giving it lovin' on the forums.

Changelog

h4. 1.2 (2010 Sep 15) * added compatibility with EEv2.x * added array_index and separator parameters in order to select result or results from an array * added reverse parameter to enable listing the parameters in reverse (easier for some PHP functions, such as explode)

Post a comment

Name:

Email:

Location:

URL:

Your comment:

Remember my personal information
Notify me of follow-up comments?

Please enter the word you see in the image below: