Jump to content

Stripping characters from a variable


globex

Recommended Posts

Hello,

 

I have a variable which holds two numbers separated by an 'x'. Like this: 100x100, or 80x34 or 480x12. How do I:

 

a) strip the first number and the x to get just the second number

b) strip the x and the last number to get just the first number

 

I'm very new at PHP so some details and simple explanations would be fantastic. Or maybe just point me in the direction of the proper documentation page.

Thanks.

Link to comment
https://forums.phpfreaks.com/topic/40862-stripping-characters-from-a-variable/
Share on other sites

Amen to Chris.

 

If you used substr with strpos you could find the position of the X and use that, but you would still have to call it twice one to get the beginning and one for the end whereas explode does it in one line and I believe is a simpler way to do it.

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.