dlewis23
05-04-2009, 03:39 PM
I did this once before but now I can't remember what it was I did to make it work.
I need do this
if($something islike $something){$show = 'that'};
What would I put where I have 'islike'?
Thanks
damon.whitt
05-04-2009, 03:44 PM
ok you are close to it
if($something == $something){$show = 'that';}
or
if($something == $something){$show = 'that';}else{$show = 'this';}
also as
if($something == $something){
$show = 'that';
}elseif($something == $something){
$show = 'other';
}else{
$show = 'this';
}
dlewis23
05-04-2009, 03:57 PM
ok you are close to it
if($something == $something){$show = 'that';}
or
if($something == $something){$show = 'that';}else{$show = 'this';}
That doesn't really work when I was doing it that way.
I'm trying to get the end users device they are on. So I start with this.
Mozilla/5.0 (iPhone; U; CPU iPhone OS 2_2_1 like Mac OS X; en-us) AppleWebKit/525.18.1 (KHTML, like Gecko) Mobile/5H11
I try to build it a few versions ahead so I can't just do like
Mozilla/5.0 (iPhone; U; CPU iPhone OS 2_2_2 like Mac OS X; en-us) AppleWebKit/525.18.1 (KHTML, like Gecko) Mobile/5H11
or
Mozilla/5.0 (iPhone; U; CPU iPhone OS 3_0_0 like Mac OS X; en-us) AppleWebKit/525.18.1 (KHTML, like Gecko) Mobile/5H11
Because the webkit version changes and I don't know what that will be. So I was trying to do it like.
if($device == 'iPhone 2_2_1'){$device_short = 'iPhone 2_2_1'}
Then I would build a few versions ahead so I don't have to update it the second a new firmware comes out.
But for some reason when I do == I end up getting the full device name or nothing at all not the shortened one. So thats why I figured it was something different for "is like" not $this == $this
abduraooft
05-04-2009, 04:01 PM
You may use strstr() (http://php.net/strstr)
venegal
05-04-2009, 04:02 PM
You might want to do that with regular expressions.
if (preg_match("/iPhone/", $device)) {$device_short = "iPhone";}
damon.whitt
05-04-2009, 04:03 PM
you have to tell the $device_short what it is to be in value or use a str_replace
$device_short = str_replace(" ", "", $device); // this will remove all spaces
is this what you are looking for?
dlewis23
05-04-2009, 04:28 PM
You might want to do that with regular expressions.
if (preg_match("/iPhone/", $device)) {$device_short = "iPhone";}
Thank you, That worked just the way I wanted.