networkthis Posted November 19, 2008 Share Posted November 19, 2008 What would be the most efficient way to do this... Lets say I have a $string that contains an * and I want to strip the * replace that part of $string* and make it $string% What is the best method for this??? preg_replace, ereg_rplace ???? Any feedback would is greatly appreciated. Thank you! Link to comment https://forums.phpfreaks.com/topic/133394-replacing-efficient-way-to-do-this/ Share on other sites More sharing options...
premiso Posted November 19, 2008 Share Posted November 19, 2008 mmm the most efficient is preg_replace I do believe. But if it is just as simple as replacing * with $string I think an easier/better way would be to use str_replace since it does not use REGEX it will be much easier and I would think quicker for something that easy. Link to comment https://forums.phpfreaks.com/topic/133394-replacing-efficient-way-to-do-this/#findComment-693769 Share on other sites More sharing options...
genericnumber1 Posted November 19, 2008 Share Posted November 19, 2008 str_replace() is much quicker than preg_replace() yes, so use it if you're simply replacing all * with some other string or character. Link to comment https://forums.phpfreaks.com/topic/133394-replacing-efficient-way-to-do-this/#findComment-693770 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.