erme Posted February 15, 2013 Share Posted February 15, 2013 Looking to remove text* where * will be a number. The below doesn't work. Can anyone shed some light? str_replace(array('text[0-9]'), Array('')) Link to comment https://forums.phpfreaks.com/topic/274524-str_replace-wildcard/ Share on other sites More sharing options...
trq Posted February 15, 2013 Share Posted February 15, 2013 preg_replace. The manual is a programmers best friend. Link to comment https://forums.phpfreaks.com/topic/274524-str_replace-wildcard/#findComment-1412597 Share on other sites More sharing options...
erme Posted February 15, 2013 Author Share Posted February 15, 2013 So something along these lines? $title = preg_replace( array('text', '%\0-9/%'), array('', ''), $crumb); Link to comment https://forums.phpfreaks.com/topic/274524-str_replace-wildcard/#findComment-1412602 Share on other sites More sharing options...
erme Posted February 15, 2013 Author Share Posted February 15, 2013 Got it working myself preg_replace(array('/[0-9]/'),array(''), $title); Link to comment https://forums.phpfreaks.com/topic/274524-str_replace-wildcard/#findComment-1412622 Share on other sites More sharing options...
PaulRyan Posted February 15, 2013 Share Posted February 15, 2013 You don't need array() in the function arguements, this will suffice: preg_replace('/[0-9]/', '', $title); Link to comment https://forums.phpfreaks.com/topic/274524-str_replace-wildcard/#findComment-1412623 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.