0

I have array of id's. I am getting id's in string in $user_id.

$array=explode(',', $user_id);

  echo http_build_query($array);

It outputs 0=3&1=4 but when I Pass $array as a parameter to controller function via url like this..

<?php echo base_url()."index.php/requesthandler/cancelRequest/$payment_id/$booking_id/$array";?>

And when I print_r($array) in controller it gives me output only string that is 'Array'.So how do I Pass that array to controller function via url?? $booking_id and $payment_id are other parameters for that function.

1 Answer 1

1

You should convet array to query string, please use http_build_query functio with url, try this

    <?php echo base_url()."index.php/requesthandler/cancelRequest
       /$payment_id/$booking_id?".http_build_query($array);?>

OR

You can also pass same string with single key

<?php echo base_url()."index.php/requesthandler/cancelRequest
       /$payment_id/$booking_id?user_ids={$user_id}"; ?>

And parse on user like this

<?php  print_r(explode(',', $this->input->get("user_ids"));?>
Sign up to request clarification or add additional context in comments.

4 Comments

when i use your first ans it gives me error uri contains disallowed characters when i click on link
@KedarB , OK please allow 0-9 char in query string... you can set allow char in /aplication/config.php file $config['permitted_uri_chars'], i would recommend 2nd option.
what is user_ids after $booking_id
@KedarB this is query string key that will be used to parse GET value see below in ans.

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.