Results 1 to 4 of 4
April 8th, 2005, 11:09 AM #1explode => delete => implode
I really need some help with this. I'm building a portfolio system into a new site that I'm consolidating my day trading site in to. I have the company symbols stored in a pipe-delimited field. Example:
So far I've been able to manipulate this data pretty well but now I've run into a roadblock. What I need to do is to, at any time, be able to individually delete one of those symbols and then group them all back together and update the database. So if I explode the string and want to remove DELL, it will end up with:
Is there an easy way to go about this that I'm totally missing?
April 8th, 2005, 11:22 AM #2
It really depends on what programming language. Some make this easier than others.
One trick that should be fairly easy in virtually any language is to add a | to the beginning and end, then replace |DELL| with |, then remove the leading and trailing |'s.
Step 1) MSFT|YHOO|DELL|AMZN -> |MSFT|YHOO|DELL|AMZN|
Step 2) |MSFT|YHOO|DELL|AMZN| -> |MSFT|YHOO|AMZN|
Step 3) |MSFT|YHOO|AMZN| -> MSFT|YHOO|AMZN
April 8th, 2005, 11:52 AM #3
In PHP, you can use the explode() function to break them apart into an array, use the unset() function to remove the element you don't want, then use impode() to put them back together into a string again with the pipe as a delimiter.Tim
consultant by day, affiliate by night
April 8th, 2005, 12:15 PM #4
By Leader in forum Midnight Cafe'Replies: 11Last Post: March 9th, 2007, 11:31 AM
By bwc in forum Midnight Cafe'Replies: 22Last Post: December 20th, 2005, 08:18 AM
By perfectG in forum Commission Junction - CJReplies: 0Last Post: March 20th, 2003, 01:59 AM