Note that there are some explanatory texts on larger screens.

plurals
  1. POHow to get an array value after explode?
    text
    copied!<p>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.</p> <p>This is my array:</p> <pre><code>$user_rate=$_POST['user_rate'];//15000|ss|Array list($total,$promo,$rate)=explode("|",$user_rate); </code></pre> <p>So I get:</p> <pre><code>$total=15000; $promo=ss; $rate=Array; </code></pre> <p>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:</p> <pre><code>foreach($rate as $val){ echo "$val&lt;br&gt;"; } </code></pre> <p>But it shows nothing. How can I get this?</p> <p>Updated : This is the code before the var is sent.</p> <pre><code>echo " &lt;tr&gt; &lt;td align=\"right\" colspan=\"3\"&gt;Total&lt;/td&gt; &lt;td align=\"right\"&gt;&lt;label for=\"promo_3\"&gt;&lt;input type=\"radio\" name=\"user_rate\" id=\"promo_3\" value=\"$ss_total|ss|$cost_ss\" /&gt;&amp;nbsp;&lt;u&gt;&lt;b&gt;".number_format($ss_total)."&lt;/b&gt;&lt;/u&gt;&lt;/label&gt;&lt;/td&gt; &lt;td align=\"right\"&gt;&lt;label for=\"promo_1\"&gt;&lt;input type=\"radio\" name=\"user_rate\" id=\"promo_1\" value=\"$net_total|nc|$cost_nr\" checked/&gt;&amp;nbsp;&lt;u&gt;&lt;b&gt;".number_format($net_total)."&lt;/b&gt;&lt;/u&gt;&lt;/label&gt;&lt;/td&gt; &lt;/tr&gt;"; </code></pre> <p><strong>AND THIS FORMAT OF VALUE CANNOT CHANGE BECAUSE I NEED IT FOR A LATER JAVASCRIPT EXTRACT</strong></p> <p>While <strong>$cost_ss</strong> and <strong>$cost_nr</strong> are derived from database query looping.</p> <pre><code>while($rec=mysql_fetch_array($result)){ $cost_ss[]=$rec['rate_ss']; $cost_nr[]=$rec['rate_nr']; } </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload