如何获得数组值后爆炸? [英] How to get an array value after explode?

查看:144
本文介绍了如何获得数组值后爆炸?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我从一个页面数组中传递的值到另一个。我可以提取前两个瓦尔由爆炸,但我不能得到它在一个阵列形成了第三个值。

这是我的数组:

  $ user_rate = $ _ POST ['user_rate']; // 15000 |不锈钢|阵列
列表($总计$促销,$率)=爆炸(|,$ user_rate);

所以我得到:

  $总额= 15000;
$促销= SS;
$率=阵列;

虽然阵列来自previous页通过循环每日速率,并把在数组中。我需要知道每个率是什么,所以我写了:

 的foreach($率$ VAL){
回声$ VAL< BR>中;
}

但是这说明不了什么。我怎样才能得到呢?

更新:这是code发送的VAR之前

 回声
&所述; TR>
< TD ALIGN = \\右\\​​合并单元格= \\3 \\>总计< / TD>
&LT; TD ALIGN = \\右\\​​&GT;&LT;标签= \\promo_3 \\&GT;&LT;输入类型= \\无线\\NAME = \\user_rate \\ID = \\promo_3 \\值= \\$ ss_total |不锈钢| $ cost_ss \\ />&nbsp;<u><b>\".number_format($ss_total).\"</b></u></label></td>
&LT; TD ALIGN = \\右\\​​&GT;&LT;标签= \\promo_1 \\&GT;&LT;输入类型= \\无线\\NAME = \\user_rate \\ID = \\promo_1 \\值= \\$ net_total |数控| $ cost_nr \\ checked/>&nbsp;<u><b>\".number_format($net_total).\"</b></u></label></td>
&所述; / TR&gt;中;

和价值本格式无法改变,因为我需要它以后JAVASCRIPT提取

$ cost_ss $ cost_nr 从数据库查询循环的。

 而($ REC = mysql_fetch_array($结果)){
$ cost_ss [] = $ REC ['rate_ss'];
$ cost_nr [] = $ REC ['rate_nr'];
}


解决方案

这可能是一个错误的 $ user_rate = $ _ POST ['user_rate']; // 15000 |不锈钢|阵列

您可以使用序列化/反序列化数组

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 is my array:

$user_rate=$_POST['user_rate'];//15000|ss|Array
list($total,$promo,$rate)=explode("|",$user_rate);

So I get:

$total=15000;
$promo=ss;
$rate=Array;

While Array comes from the previous page by looping the daily rate and put in an array. And I need to know what each rate is, so I wrote:

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

But it shows nothing. How can I get this?

Updated : This is the code before the var is sent.

echo "
<tr>
<td align=\"right\" colspan=\"3\">Total</td>
<td align=\"right\"><label for=\"promo_3\"><input type=\"radio\" name=\"user_rate\" id=\"promo_3\" value=\"$ss_total|ss|$cost_ss\" />&nbsp;<u><b>".number_format($ss_total)."</b></u></label></td>
<td align=\"right\"><label for=\"promo_1\"><input type=\"radio\" name=\"user_rate\" id=\"promo_1\" value=\"$net_total|nc|$cost_nr\" checked/>&nbsp;<u><b>".number_format($net_total)."</b></u></label></td>
</tr>";

AND THIS FORMAT OF VALUE CANNOT CHANGE BECAUSE I NEED IT FOR A LATER JAVASCRIPT EXTRACT

While $cost_ss and $cost_nr are derived from database query looping.

while($rec=mysql_fetch_array($result)){
$cost_ss[]=$rec['rate_ss'];
$cost_nr[]=$rec['rate_nr'];
}

解决方案

this probably be a wrong $user_rate=$_POST['user_rate'];//15000|ss|Array

you can use serialize / unserialize for array

这篇关于如何获得数组值后爆炸?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆