bl4ck
bl4ck

Reputation: 43

How to Get data From url value parameter $_GET in PHP

sorry i a begginer of php. I have url example here: http://example.com?category=software-hardware .Actual of category is Software & Hardware I using this script to get url above

foreach ( $key as $value ) {
    $c = array(' ', '&-');
    $d = array('-', '');
    echo "<a href=\"category/".strtolower(str_replace($c, $d, $value->kategori_laporan))."\" class=\"list-group-item\">".$value->kategori_laporan."</a>";   
}

How To get data from my condition url.? Sorry, i bad using english. I want to create url like category from slideshare. Please help me.! Thanks.!

Upvotes: 0

Views: 1548

Answers (2)

Rahul Patel
Rahul Patel

Reputation: 5246

$_GET is an associative array having all the query string keys values.

You can get value of any query string parameter from this array by passing the key of query string parameter.

To get category you can use $_GET["category"] in your case.

Upvotes: 0

Marko Krstic
Marko Krstic

Reputation: 1447

you can fetch it like:

$cat = $_GET['category'];

and you don't need any foreach

Upvotes: 1

Related Questions