mavera2 Posted May 5, 2012 Share Posted May 5, 2012 In my codes several times i do this kind of replacement: $userlimit = str_replace('5000','5000+', $userlimit ); Is there a shorter way to do this? I tried this by passing to str_replace by reference. But not worked. Thank you Quote Link to comment https://forums.phpfreaks.com/topic/262118-newbie-question/ Share on other sites More sharing options...
PFMaBiSmAd Posted May 5, 2012 Share Posted May 5, 2012 Is there a shorter way to do this? Not without knowing the context and conditions and values under which it would need to work. What is typically in $userlimit? Is it just the number or is it a longer string of some kind? How is this value being used? Is it in an update query, in which case, you can probably just do it in the query? Is the value (5000) a variable or a fixed number? Just one line of code taken out of context doesn't define a programming problem. Anything we come up with for just that one line would take more statements, but in the overall scheme of what you are doing, once you tell us that, you can probably greatly reduce the number of lines of code. Quote Link to comment https://forums.phpfreaks.com/topic/262118-newbie-question/#findComment-1343296 Share on other sites More sharing options...
mavera2 Posted May 5, 2012 Author Share Posted May 5, 2012 Is there a shorter way to do this? Not without knowing the context and conditions and values under which it would need to work. What is typically in $userlimit? Is it just the number or is it a longer string of some kind? How is this value being used? Is it in an update query, in which case, you can probably just do it in the query? Is the value (5000) a variable or a fixed number? Just one line of code taken out of context doesn't define a programming problem. Anything we come up with for just that one line would take more statements, but in the overall scheme of what you are doing, once you tell us that, you can probably greatly reduce the number of lines of code. Thank you for reply. $userlimit was a 90-100 character long string. It is used to mention user about his current limit, and limit options. 5000 is a fixed value. Quote Link to comment https://forums.phpfreaks.com/topic/262118-newbie-question/#findComment-1343340 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.