Get value before and/or after "x" in a string?

Discussion in 'PHP' started by misterdh, Aug 6, 2010.

  1. #1
    Hi,

    I am working with screen resolutions and so far I managed to get the users screen resolution into a cookie which states "1440x900" (My resolution).

    I just wonder how I can get width and height in two different strings? Something that removes "x" and everything after it to get width and vice verca for height..
    :cool:
     
    misterdh, Aug 6, 2010 IP
  2. Kaizoku

    Kaizoku Well-Known Member

    Messages:
    1,261
    Likes Received:
    20
    Best Answers:
    1
    Trophy Points:
    105
    #2
    You can do this with one line.

    
    list($x, $y) = explode('x', "1440x900"); // replace with string
    
    PHP:
     
    Kaizoku, Aug 6, 2010 IP
    srobona likes this.
  3. misterdh

    misterdh Peon

    Messages:
    90
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #3
    That was easy! lol

    Thanks alot! :)

    Have a nice one!
     
    misterdh, Aug 6, 2010 IP