Hello, there is such a question: how to transfer not many values ​​to a gett?
For example, there is a link

http://www.dostavka.ru/request/ProductComparePageRequest? product_id = 6490057-6553652-6582008

At the end, several IDs go to the product_id values, and they process them in their own way. The question itself: how to take this value correctly and continue to work with these IDs?

    2 answers 2

    There are two fundamentally different ways.

    1. script.php? product_id = 6490057-6553652-6582008

    then

     $produnct_ids = explode('-',$_GET['product_id']); //$produnct_ids[1] == 6553652; 
    1. script.php? product_id [] = 6490057 & product_id [] = 6553652 & product_id [] = 6582008;

    then

     $produnct_ids = $_GET['product_id']; //$produnct_ids[1] == 6553652; 

    The second method is preferable. Client side implementation:

     <input type="text" name="produnct_id[]" value="6490057" /><br /> <input type="text" name="produnct_id[]" value="6553652" /><br /> <input type="text" name="produnct_id[]" value="6582008" /><br /> 

    Pay attention to the brackets !!!

    UPD
    The resulting $ product_ids arrays are identical. Through the echo it can be output as follows:

     echo '<pre>'.print_r($product_ids,true).'</pre>'; 

    or so:

     echo implode(',',$product_ids); 

    or so:

     foreach($product_ids as $id){ print($id.'<br />'); } 
    • Thanks, the last question is right here for children, according to the first method, we get an array, and how to derive all of it through echo? Ie all 3 values, in a cycle - dogmar
    • see Update - knes

    Why is it so difficult? :))) I would do that:

    http://www.dostavka.ru/request/ProductComparePageRequest?product_id=6490057,6553652,6582008

    On the server side:

     if($_GET[product_id]) $array_id = split(',',$_GET[product_id]); //Из полученной строки сплитим значения по запятой. 

    Next, we have an array with aidis. and do with them anything.