We use cookies to improve your experience. No personal information is gathered and we don't serve ads. Cookies Policy.

ExpressionEngine Logo ExpressionEngine
Features Pricing Support Find A Developer
Partners Upgrades
Blog Add-Ons Learn
Docs Forums University
Log In or Sign Up
Log In Sign Up
ExpressionEngine Logo
Features Pro new Support Find A Developer
Partners Upgrades
Blog Add-Ons Learn
Docs Forums University Blog
  • Home
  • Forums

How To Explode a Delimiter

Development and Programming

webster10's avatar
webster10
9 posts
15 years ago
webster10's avatar webster10

What is the best way to explode a delimiter. I have commas within entries and I want to replace the commas within the database entries with Any suggestions?

       
Ingmar's avatar
Ingmar
29,245 posts
15 years ago
Ingmar's avatar Ingmar

What about using PHP’s explode() in your template?

       
webster10's avatar
webster10
9 posts
15 years ago
webster10's avatar webster10

Is there not a EE function or plugin that would handle replacing characters. For instance within this entry there are multiple items separated by a comma. I would like to replace the comma with a . Are you saying that the best way to this is by using a PHP query and then the explode function?

{exp:weblog:entries weblog="guitars"}
{series}
{/exp:weblog:entries}
       
Ingmar's avatar
Ingmar
29,245 posts
15 years ago
Ingmar's avatar Ingmar

You could put explode() in a plugin, too, of course. If you use PHP on Output you can easily let EE do it’s thing, as it were, then treat the results with a dose of PHP. I’m sure there are some third-party plugins, too.

       
Adrian Macneil (Crescendo)'s avatar
Adrian Macneil (Crescendo)
28 posts
15 years ago
Adrian Macneil (Crescendo)'s avatar Adrian Macneil (Crescendo)

webster, how would you want the ee template code to look (it would be easy to whip up an EE plugin to replace the php function, seems pretty useful to me). Is this what you are thinking?

{exp:explode input="blah,one,two,three" delimiter=","}
{item}

{/exp:explode}
       
Adrian Macneil (Crescendo)'s avatar
Adrian Macneil (Crescendo)
28 posts
15 years ago
Adrian Macneil (Crescendo)'s avatar Adrian Macneil (Crescendo)

Actually it looks like this plugin would do the trick

       

Reply

Sign In To Reply

ExpressionEngine Home Features Pro Contact Version Support
Learn Docs University Forums
Resources Support Add-Ons Partners Blog
Privacy Terms Trademark Use License

Packet Tide owns and develops ExpressionEngine. © Packet Tide, All Rights Reserved.