How to get an array value after explode?

前端 未结 6 1204
感动是毒
感动是毒 2021-01-24 17:39

I have passed a value from one page to another in array. I can extract first two vars by explode but I can\'t get the third value which is formed in an array out.

This i

6条回答
  •  悲&欢浪女
    2021-01-24 17:58

    ok, many answers and no luck... i'll try it again:

    you have an array $rate before you submit your form:

    foreach($rate as $val){
       echo "$val
    "; }

    and you want to add $ss_total and the string "ss" and submit it so you need to:

    $newarray = array('rate'=>$rate, 'type'=>'ss', 'ss_total'=>$ss_total); 
    // now you have a 2-dimensional array ($newarray)
    
    // the next step is to prepare it for form-submitting (serialize and base64_encode):
    $stringvalue = base64_encode(serialize($newarray));    
    
    // ok, now you are able to submit it as radio-field-value:
    echo '';
    

    when the form is submitted you get a serialized and encoded string in $_POST['user_rate'], you can do an echo if you'd like to see how it looks.

    Now you need to base64_decode and unserialize:

    $arr = unserialize(base64_decode($_POST['user_rate']));
    

    and you have now full access to your array:

    echo $arr['type']."
    "; echo $arr['ss_total']."
    "; echo $arr['rate']['index_of_rate']; // i dont know the keys of rate array...

    access $arr in javascript:

    echo "";
    

    I hope you get it now.

提交回复
热议问题