Sorry to be using this list for this kind of questions but I need some
expert help on this one so...
I have a string of numbers separated with comma (,). Like so:
1,2,3,4,5,12,55,72,182,211,321
There can't be any duplicates in this string or my script won't work.
Unfortunately this happens for some reason I haven't figured out yet so for
the time being I have to try and remedy the effect and not the cause. 8(
I've been fooling around with regexps as they seem to be the right tool for
the job but I can't for the life of me understand how to get them to do what
I want.
I know how to find a given string with a regexp but not a dynamically
created one. For instance, lets say that my string looks like this:
4,5,211,211,211,211,223,231
In this case I'd like the regexp to find the 211's and replace them with one
instance of 211:
4,5,211,223,231
Should I use a regexp within a regexp for this? What would it look like? I
am getting better at regexps but this seems to be way over my head. I don't
mind using more than one iteration either so if I need a couple of regexps
to do the job that's fine with me.
I'm on a deadline so any and all ideas and suggestions are more than
welcome.
TIA.
Best regards,
Martin Edelius
Spirex Digital Design
--------------------------------
www: http://www.spirex.se
Mail: martin....@spirex.se
Phone: +46-31-514651, 0708-113711
Fax: +46-31-514331
Aröds Industriväg 3c
S-422 43 Hisings Backa
--------------------------------
If I haven't got back to you or done what I'm supposed to, let me know again
as I have too much to do for my own good...
--
PHP 3 Mailing List <http://www.php.net/>
To unsubscribe, send an empty message to php3-uns...@lists.php.net
To subscribe to the digest, e-mail: php3-diges...@lists.php.net
To search the mailing list archive, go to: http://www.php.net/mailsearch.php3
To contact the list administrators, e-mail: php-lis...@lists.php.net
Nick
I don't know where the duplicate entries will occur or how many times in a
row so I have to find a way to handle everything automatically. 8/
Thanks for the feedback.
Best regards,
Martin Edelius
Spirex Digital Design
--------------------------------
www: http://www.spirex.se
Mail: martin....@spirex.se
Phone: +46-31-514651, 0708-113711
Fax: +46-31-514331
Aröds Industriväg 3c
S-422 43 Hisings Backa
--------------------------------
If I haven't got back to you or done what I'm supposed to, let me know again
as I have too much to do for my own good...
might not be the best way but you said you were looking for a quick and
dirty solution.
while(list($pos,$val) = each($data)){
$temp[(string)$val] = $val;
and it worked like a charm. 8)
Thanks a lot for the help.
-- Martin
No problem dude,