#1
  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    May 2013
    Posts
    6
    Rep Power
    0

    How to filter get_browser output


    Hi

    I'm using get_browser(null, true) to display users browser, OS etc. for logging purposes.

    However, I don't want to log the complete get_browser output everytime.

    Example:
    If the output were:
    Code:
    Array
    (
        [browser_name_regex] => ^mozilla/5\.0 (windows; .; windows nt 5\.1; .*rv:.*) gecko/.* firefox/0\.9.*$
        [browser_name_pattern] => Mozilla/5.0 (Windows; ?; Windows NT 5.1; *rv:*) Gecko/* Firefox/0.9*
        [parent] => Firefox 0.9
        [platform] => WinXP
        [browser] => Firefox
    and I want to boil it down to:

    Code:
    Firefox 0.9
    WinXP
    I've tried using explode, but I can't get it to work properly.

    This is what I tried:
    PHP Code:
    $ex=explode(' 'get_browser(nulltrue));
    echo 
    'OS: '.$ex[4].; 
    How would I go about doing that?
  2. #2
  3. No Profile Picture
    Lost in code
    Devshed Supreme Being (6500+ posts)

    Join Date
    Dec 2004
    Posts
    8,317
    Rep Power
    7170
    get_browser already returns an array, you don't need to explode it.
    PHP Code:
    $ex get_browser(nulltrue);
    echo 
    $ex['browser']; 
    PHP FAQ

    Originally Posted by Spad
    Ah USB, the only rectangular connector where you have to make 3 attempts before you get it the right way around
  4. #3
  5. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    May 2013
    Posts
    6
    Rep Power
    0
    Originally Posted by E-Oreo
    get_browser already returns an array, you don't need to explode it.
    PHP Code:
    $ex get_browser(nulltrue);
    echo 
    $ex['browser']; 
    Thank you, thats exactly what I was looking for.
    Last edited by dnn; May 18th, 2013 at 12:57 PM. Reason: Misread answer

IMN logo majestic logo threadwatch logo seochat tools logo