Waqas Ali Waqas Ali - 25 days ago 7
PHP Question

How to pass Object or array with Query string in PHP

I am learning PHP and wondering How do i pass an array or object with query string using php ? I do google it but could not find a good answer about it.
Here what i wondering ?

http://www.example.com/abc?array('a','b','c')

http://www.example.com/abc?object("a":"a","b":"b")

Answer

That is my prefer ..you can try it

<?php
$link = "http://www.example.com/abc?";
//try with object
// $a = new stdClass();
// $a->a = "a";
// $a->b = "b";
//try with array
$a = ["a","b","c"];
header("location:{$link}param=".json_encode($a));

www.example.com/abc

<?php 
$data = json_decode($_GET["param"]);
var_dump($data);
Comments