0

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")

3
  • This is not the efficient and the right way of passing of values. Why don't you use json_encode or paramitized values for this? Commented Nov 9, 2016 at 5:24
  • Can you please quote me an example,as i am looking for best practises.L. Herrera Commented Nov 9, 2016 at 5:26
  • First you have to show us those values you want to pass through the URL. Commented Nov 9, 2016 at 5:50

1 Answer 1

2

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);
Sign up to request clarification or add additional context in comments.

1 Comment

Thank you,this is what i am looking for @David JorHpan

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.