1

I'll try to make this short and sweet. Pretty much I am passing some variables from one page to the next and I want to rebuild that array on the next page.

<?php
 /* $user is and array of data specific to the user */
 $user_id = $user["userId"]; // we'll pretend the value is 13
 $manager_ids = array(42,56,76);
 $url = './mod-super-admin/edit-relationship.php?edit=true&repId=' . $user_Id  . '&';
 $url .= http_build_query($manager_ids, 'manager_');
?>

I am using that $url and echoing inside an href so that user can be editing on the next page. When I click that anchor tag, it brings me to:

http://localhost:8888/applicationName/mod-super-admin/edit-relationship.php?edit=true&repId=13&manager_0=42&manager_1=56&manager_2=76

This is fine and dandy and is exactly what I want, BUT I am having trouble bringing back those value that were in the array back into an array. The catch here is I DO NOT want edit => true and repId => 13 in that array. I just want those managers to go back into an array.

Thanks for looking!

1 Answer 1

2

I would propose making a managers array in the URL:

$url .= http_build_query(array('managers' => $manager_ids));

Yields:

managers%5B0%5D=42&managers%5B1%5D=56&managers%5B2%5D=76

When received by PHP it will be interpreted as:

managers[0]=42&managers[1]=56&managers[2]=76

So $_GET['managers'] will yield:

Array
(
    [0] => 42
    [1] => 56
    [2] => 76
)
Sign up to request clarification or add additional context in comments.

1 Comment

Just tested this and it works wonderfully and exactly how I wanted it to. tysm! Question solved and UpVote for you! :)

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.