Home > Back-end >  Get data from URL with value
Get data from URL with value

Time:01-27

I have URL like this :

http://127.0.0.1:8000/hasil-transaksi?data[0][]=0000260&data[0][no_transaksi]=KRJ22010001

How to get KRJ22010001 from that URL?

CodePudding user response:

TO get querystring you can use the Request Object. Following example for your controller:

public function exampleShow(\Illuminate\Http\Request $request)
{
    dd( $request->input('no_transaksi') );
}

CodePudding user response:

Use urldecode to decode your string, parse_​url to get the query and parse_​str to get its components:

<?php 

$url = 'http://127.0.0.1:8000/hasil-transaksi?data[0][]=0000260&data[0][no_transaksi]=KRJ22010001';
$url_decoded = urldecode($url);
$query = parse_url($url_decoded, PHP_URL_QUERY);
parse_str($query, $parsed_query);

echo $parsed_query['data'][0]['no_transaksi'];

will output KRJ22010001

  •  Tags:  
  • Related