문제

eregi_replace('[0-9]+\.+[0-9]','',$cart['unit']);

How to change it to preg_replace?

I get an error: Warning: preg_replace() [function.preg-replace]: Unknown modifier '+' in ---

도움이 되었습니까?

해결책

You can use your existing Regex almost unchanged in a preg_replace(). Just add delimiters and a case-insensitive modifier. You get

preg_replace('#[0-9]+\.+[0-9]#i','',$cart['unit']);

In fact, the case-sensitivity is irrelevant since your pattern only matches 0-9 and .

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top