How to explode url string?

code:

<?php
    include('conn.php');
    $student_id = $_SESSION['student_id'];
    $college_name = $_GET['college_name'];
    $college_name22 = explode('(', $college_name);
    if(preg_match('#\((.*?)\)#', $college_name, $match))
    {
        $match[1] = lcfirst($match[1]);
    }
    else
    {
        $match[1] = 'All';
    }

      

? >

If url has a string like

cstest/view.php?college_name=Agra%20Public%20Institute%20of%20Technology%20&%20Computer%20Education,%20Artoni%20(Pharmacy)

      

and I want to blow up the following line ie

Agra%20Public%20Institute%20of%20Technology%20&%20Computer%20Education,%20Artoni%20(Pharmacy)

      

when i return echo $ college_name it only shows (Agra Public Institute of Technology) but not the full name i.e. (Agra State Institute of Technology and Computer Education, Artoni) and $ match [1] contain (pharmacy), which is not displayed when I print $ match [1] shows "All". So how can I fix this problem?

thank

+3


source to share


1 answer


&

has special meaning in the url. the value $_GET['college_name']

is "Agra% 20Public% 20Institute% 20of% 20Technology% 20". &

marks the start of a new parameter.

If the ampersand is properly escaped like %26

, it will be much easier for you.



You can try pasting var_dump($_GET)

and see what kind of data you are working with.

+2


source







All Articles