multiple conditions using eregi_replace, help needed please

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
User avatar
massiveone
Forum Commoner
Posts: 29
Joined: Tue Jun 18, 2002 4:39 pm
Location: Canada
Contact:

multiple conditions using eregi_replace, help needed please

Post by massiveone »

Hello, If anyone could answer this that would be much appreciated the problem is as such. i need to strip the front and end of a variable off

$sku="00-R2-1001XL";
eregi_reaplace ('(00-)?','',$sku);

This manages to strip the 00- off.

eregi_reaplace ('X*[SML]$','',$sku);

This manages to stip the size denomintor off the variable

HOW DO I COMBINE BOTH IN ONE EREGI_REPLACE COMMAND?
THANKS
:roll:
User avatar
Stoker
Forum Regular
Posts: 782
Joined: Thu Jan 23, 2003 9:45 pm
Location: SWNY
Contact:

Post by Stoker »

Use preg instead..

Code: Select all

<?php 

  $sku = pregi_replace('/(00|XXL$|XL$|L$|M$|S$)/','',$sku);

?>



hmm soneone should put it in the sticky stuff to never us ereg!
or they should remove it from the manual and not have it compiled in by default..
Post Reply