Malinga

Well-known member
  • Jul 20, 2006
    61,301
    1,013
    113
    PHP:
    $browser = $_SERVER['HTTP_USER_AGENT'];
    
    if (preg_match('/MSIE/i',$browser)) {
        echo "you are using Microsoft Internet Explorer";    
    } else if (preg_match('/Firefox/i',$browser)) { 
        echo "you are using Firefox";    
    } else if (preg_match('/Chrome/i',$browser)) {
        echo "you are using Chrome";    
    }

    oya ekakvath namainum browser eka ehema namai kiyalath display venna oona needa? :)
     
    • Like
    Reactions: mldarshana

    HallowMan

    Well-known member
  • Jan 10, 2010
    5,789
    1,005
    113
    In Python there's a similar data structure to an Array in PHP, it's called a Dictionary. All interpreted languages are following a much similar pattern hope this will help you.


    ex: in Python
    Code:
    employee_salary = {'Saman': 5000, 'Ruwan': 2000, 'Piyal': 7000}
    
    for key, val in sorted(employee_salary.items()):
         print key, val

    easy as that.

    just a simple Google search ("arrays in php") retrieved the below link and you are not putting a single effort accomplish your task by yourself. Out there the competition is aggressive so you need to prepare yourself.

    http://php.net/manual/en/language.types.array.php
     

    Malinga

    Well-known member
  • Jul 20, 2006
    61,301
    1,013
    113
    :yes: ඔක්කොම අතට පයට දුන්නම අගයක් නෑ නෙ :lol:

    :yes::yes: එයාටත් ඒ කෝඩ් වලින් වෙන්නෙ මොකක් ද කියල තේරුම් ගන්න ඒක හොඳයි තමයි.
     

    ||~R_girl~||

    Member
    Mar 21, 2008
    34,536
    460
    0
    In Python there's a similar data structure to an Array in PHP, it's called a Dictionary. All interpreted languages are following a much similar pattern hope this will help you.


    ex: in Python
    Code:
    employee_salary = {'Saman': 5000, 'Ruwan': 2000, 'Piyal': 7000}
    
    for key, val in sorted(employee_salary.items()):
         print key, val

    easy as that.

    just a simple Google search ("arrays in php") retrieved the below link and you are not putting a single effort accomplish your task by yourself. Out there the competition is aggressive so you need to prepare yourself.

    http://php.net/manual/en/language.types.array.php
    agree
    thanks anyway
     

    wpmanoj

    Well-known member
  • Nov 18, 2010
    2,648
    6,412
    113
    sudu php kiyanne saralawama server side language ekak. fb wage nithra wenaswena yam yam awastha waladi wada karanna ona widiya liyala thiyanna puluwan niyama pahasuwen dynamic website hadana language ekak. php c lang ekata tikak lagai . habai c walata wada 100000 gunayak lesi. php open kiyala free kiyala dannawa athine. i recm dat php best dan other all languages. mokada mama asp perl thuth tharamak danna nisa kiyanne . wada krana kota ena onema gataluwakata udaw wenna million peples loke hama thanama balagena innawa. php.net eketh mewata onatharam udaw thiyanawa. php lang walin hadapu web site godak ewaye url walin dana ganna puluwan. eg: elakiri.com/forum/showthread.php?t=1372390& menna me wage php kiyala ekak enawa. hodatama dana ganna php not= java, css, html walin kerena wada walata kiyala.
    thawa mona hari dana ganna onenam kiyanna mama enawa sin gala udawwata

    dakke pahuwela naththan denawa udawwa sin gala:lol::lol:
     
    Last edited:

    ||~R_girl~||

    Member
    Mar 21, 2008
    34,536
    460
    0
    fuck off asshole
    dont poo on my thread too
     

    Ayeshlive

    Well-known member
  • Jul 1, 2011
    10,570
    943
    113
    *̶͑̾̾​̅ͫ͏̙̤g͛͆̾ͫ̑͆&
    Write a PHP script to detect the type of browser used to display the script. The
    information about the browser being used can be found in the value of a special
    reserved PHP variable (more accurately an array element)
    $_SERVER['HTTP_USER_AGENT'] . You need to use a built-in PHP string
    function to check for three keywords in $_SERVER['HTTP_USER_AGENT']:
    „MSIE‟, „Firefox‟ and „Chrome‟. If „MSIE‟ is found, output “you are using Microsoft
    Internet Explorer”; If „Firefox‟ is found, output “you are using Mozilla Firefox”; If
    „Chrome‟ is found, output “you are using Google Chrome”; If none of the three is
    found, output “you are using a browser other than Microsoft Internet Explorer,
    Mozilla Firefox and Google Chrome”. See
    http://www.useragentstring.com/pages...gentstring.php for a list of User Agent
    Strings for different browsers.


    ---------
    Use strpos() instead of preg matches.

    <?php
    /*$hay is user agent of the request and if strpo returned true, print the text.
    */
    $hay = $_SERVER['HTTP_USER_AGENT'];
    if strpos('MSIE', $hay) {
    print "You are using IE";
    }
    elseif strpos('Firefox', $hay) {
    print "firefox";
    }
    elseif strpos('Opera'. $hay) {
    print "opera";
    }
    ...
    ?>