extract an array into seperate variable
i have array counts amount of times different text used. display amount of times used. array printed out , 1 long string.
$opt = array(
'delone: howmuch' => 0,
'deltwo: howmuch'' => 0,
'delthree: howmuch'' => 0,
'delfour: howmuch'' => 0,
);
while ($row_rspayone = mysql_fetch_assoc$row_rspayone)) {
if (array_key_exists($row_rspayone['payment_type'], $opt)) {
$opt[$row_rspayone['pay_op']]++;
}
}
print_r($opt);
the current output is
array ( [delone: howmuch] => 19 [deltwo: howmuch] => 34 [delthree: howmuch] => 15 [delfour: howmuch] => 9 )
i want split each value separate variable can use the results separately
i have tried
extract($opt);
echo $bal = explode (" ", $opt);
echo $bal[0];
echo $bal[1];
echo $bal[2];
echo $bal[3];
but not getting output
could use foreach loop go through $opt array , assign $variable below:
$i = 0;
foreach ($opt $key => $value) {
$variable[$i] = "$key; $value";
$i++;
}
echo "<p>".$variable[0]."</p>";
echo "<p>".$variable[1]."</p>";
echo "<p>".$variable[2]."</p>";
echo "<p>".$variable[3]."</p>";
More discussions in Dreamweaver support forum
adobe
Comments
Post a Comment