EllisLab text mark
Advanced Search
1 of 2
1
   
Plugin: PHPStringFun
Posted: 05 September 2006 04:18 AM   [ Ignore ]
Avatar
Joined: 2002-12-20
388 posts

In response to a particular problem posed here on the forums, I copy’n'pasted together a quick plugin that acts as a gateway to PHP’s string functions without needing to activate PHP in a template. It’s attached to this post.

Derek made me improve it a bit, but he doesn’t want to add it to the main plugins repository until I’ve weeded out from it any PHP functions that won’t work within it. Rather than sit and test every PHP function, most of which I’ve never used and don’t know, I thought it might be easier to ask the community if they can see from the following list of PHP functions which ones will be problematic inside PHPStringFun.

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, vfprintf, vprintf, vsprintf, wordwrap.

Whichever ones anybody points out I’ll remove from the array of allowed functions inside the plugin.

Hey, it’s worth a try.

File Attachments
pi.phpstringfun.txt  (File Size: 4KB - Downloads: 1251)
 Signature 

Who ain’t a slave? - Ishmael

 
Posted: 14 November 2006 07:11 PM   [ Ignore ]   [ # 1 ]   [ Rating: 0 ]
Avatar
Joined: 2004-05-14
20504 posts

Do you know I never saw this? I added it to the wiki.

 
Posted: 15 November 2006 08:28 AM   [ Ignore ]   [ # 2 ]   [ Rating: 0 ]
Avatar
Joined: 2002-02-05
462 posts

I remember seeing this post but I was to busy to try the plugin at that time… and forgot about it red face

Great plugin, just did some testing and I absolutely love it!

Thanks Adam.

[EDIT] @Lisa, thanks for adding it to the Wiki.

 
Posted: 17 November 2006 06:49 PM   [ Ignore ]   [ # 3 ]   [ Rating: 0 ]
Avatar
Joined: 2006-03-26
1664 posts

In my effort to remove as much PHP from my templates as possible, I will give this a shot. I just found a place where I’m using ‘str_replace’ so I’ll try re-doing that with this plugin, thanks!

 Signature 

ryan masuga
—————
Masuga Design | devot:ee
@masuga | @masugadesign | @devot_ee

 
Posted: 17 November 2006 07:23 PM   [ Ignore ]   [ # 4 ]   [ Rating: 0 ]
Avatar
Joined: 2006-03-26
1664 posts

Is there any obvious reason this isn’t working?

{exp:phpstringfun function="str_replace" par1="/" par2="x"}/blah/blah2/blah3{/exp:phpstringfun} 

Results in:

That should replace every slash with an x, but it looks like it’s replacing the first one and stopping there. Any suggestions?

 Signature 

ryan masuga
—————
Masuga Design | devot:ee
@masuga | @masugadesign | @devot_ee

 
Posted: 17 November 2006 07:24 PM   [ Ignore ]   [ # 5 ]   [ Rating: 0 ]
Avatar
Joined: 2002-04-29
26055 posts

Ryan, there already is a str_replace plugin. smile I don’t have the link to it handy, but you should be able to find it in the plugins list.

 
Posted: 17 November 2006 08:11 PM   [ Ignore ]   [ # 6 ]   [ Rating: 0 ]
Avatar
Joined: 2006-03-26
1664 posts

Why, you’re right! Thanks!

For anyone else: Here’s the thread for the Find and Replace plugin, as created by Lodewijk. This plugin can also found on the Plugins page.

 Signature 

ryan masuga
—————
Masuga Design | devot:ee
@masuga | @masugadesign | @devot_ee

 
Posted: 27 December 2007 09:02 PM   [ Ignore ]   [ # 7 ]   [ Rating: 0 ]
Avatar
Joined: 2006-07-09
299 posts

does anyone know what happened to the phpstringfun plugin? Can’t find it anymore!

 Signature 

Erwin van Lun,
futurist, founder Chatbots.org (virtual agent/assistant/chat bot community)

 
Posted: 27 December 2007 11:34 PM   [ Ignore ]   [ # 8 ]   [ Rating: 0 ]
Avatar
Joined: 2006-03-26
1664 posts

Wait…isn’t it at the top of this thread?

 Signature 

ryan masuga
—————
Masuga Design | devot:ee
@masuga | @masugadesign | @devot_ee

 
Posted: 20 February 2008 05:03 PM   [ Ignore ]   [ # 9 ]   [ Rating: 0 ]
Avatar
Joined: 2006-11-06
2 posts

i know this was posted a while ago, but i didn’t know about it until today. THANK YOU THANK YOU THANK YOU THANK YOU THANK YOU THANK YOU (ad infinitum)

 
Posted: 22 March 2008 04:07 PM   [ Ignore ]   [ # 10 ]   [ Rating: 0 ]
Joined: 2008-03-05
130 posts

Don’t forget: when uploading to the plugins folder, change the extension from ...

  pi.phpstringfun.txt

... to ...

  pi.phpstringfun.php

Documentation is then available in the Plugins manager by clicking on the plugin name/link.

 
Posted: 27 April 2008 05:15 AM   [ Ignore ]   [ # 11 ]   [ Rating: 0 ]
Avatar
Joined: 2007-12-24
163 posts

Mega-super-awesome-cool plugin.

 Signature 

Trifecta Interactive | Austin, TX

 
Posted: 10 June 2008 11:09 AM   [ Ignore ]   [ # 12 ]   [ Rating: 0 ]
Avatar
Joined: 2008-02-15
1085 posts

This plugin is frickin’ excellent. So outstanding in fact, that today will forever be known to me as ‘phpstring fun day’. Mark it down everyone, 10th June.

 Signature 

Andy Harris | Pepper Digital | Malvern, UK | Twitter

 
Posted: 10 June 2008 11:45 AM   [ Ignore ]   [ # 13 ]   [ Rating: 0 ]
Avatar
Joined: 2002-12-20
388 posts

A toast!

 Signature 

Who ain’t a slave? - Ishmael

 
Posted: 14 June 2008 10:05 AM   [ Ignore ]   [ # 14 ]   [ Rating: 0 ]
Avatar
Joined: 2008-02-15
1085 posts

Has anyone gotten this to work with money_format? I have a string and I want to display it formatted in good old British Pounds Sterling. But I can’t get it to work…

 Signature 

Andy Harris | Pepper Digital | Malvern, UK | Twitter

 
Posted: 14 June 2008 10:35 AM   [ Ignore ]   [ # 15 ]   [ Rating: 0 ]
Avatar
Joined: 2006-04-15
12649 posts

Hi Andy,

Just gave it a try here and couldn’t get it to work but I am wondering looking at the documentation page on php.net for money_format and seeing these notes :

Note: The function money_format() is only defined if the system has strfmon capabilities. For example, Windows does not, so money_format() is undefined in Windows.

Note: The LC_MONETARY category of the locale settings, affects the behavior of this function. Use setlocale() to set to the appropriate default locale before using this function.

Wonder if those have anything to do with it at all? There is at least one other function in this plugin which I couldn’t get to work some time back. Can’t quite remember which one it was now but overall this really is a fantastic plugin. I see the way it works so I am thinking that this is probably more a server issue than the plugin. I could be wrong on that though.

Don’t know if that helps at all?

Best wishes,

Mark

 Signature 

Shopping Cart Plugin | Full List Of Add-Ons | About Me
——————————————————————————————
2.x Bug Tracker | Upgrade Errors

 
1 of 2
1