Jump to content

Newbie question


mavera2

Recommended Posts

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

 

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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.

 

 

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.