How to add a textbox value to a userarray in php
I got a n number of textbox values which i able to fetch it through a variable ...My question is that i got a array the source is shown below
for ($x = 1; $x <= $num; $x++) {
$userArray[] = $this->input->post("select" . $x . "");
$quantity = $this->input->post('Quantity'.$x);
$quantity = $quantity.(" ");
echo $quantity;
output of quantity is 12345 000000 12345
}
if (is_array($userArray) && !empty($userArray))
{
foreach ($userArray as $user)
{
$row = explode(',', $user);
echo implode(",",$row);
// print_r($row);
$productName = (isset($row[0]) ? $row[0] : '');
// print_r($productName);
OUTPUT 3 IN 1 INCENSE STICKS JAI GANESH,3 IN 1 INCENSE STICKS JAI GANESH,3 IN 1 INCENSE STICKS JAI GANESH,
$barcode = (isset($row[1]) ? $row[1] : '');
// print_r($barcode);
OUTPUT 683988 683988 683988
$quantity = $this->input->post("Quantity" . $x . "");
// print_r($quantity);
THE PROBLEM ARISES HERE OUTPUT COMES LIKE Quantity1 Quantity1 Quantity1
$flag = $this->cartmodel->productCategory($category);
// print_r($flag);
}
开发者_如何学Python }
i need the output of quantity to be added in the user array.. how to achieve this.. thanks for ur time
final output should be
3 IN 1 INCENSE STICKS JAI GANESH 683988 12345
3 IN 1 INCENSE STICKS JAI GANESH 683988 000000
3 IN 1 INCENSE STICKS JAI GANESH 683988 12345
Maybe:
for ($x = 1; $x <= $num; $x++) {
$userArray[] = $this->input->post("select" . $x . "");
//$quantity = $this->input->post('Quantity' . $x);
//$quantity = $quantity . (" ");
//echo $quantity;
//output of quantity is 12345 000000 12345
if (is_array($userArray) && !empty($userArray)) {
foreach ($userArray as $user) {
$row = explode(',', $user);
echo implode(",", $row);
// print_r($row);
$productName = (isset($row[0]) ? $row[0] : '');
// print_r($productName);
//OUTPUT 3 IN 1 INCENSE STICKS JAI GANESH,3 IN 1 INCENSE STICKS JAI GANESH,3 IN 1 INCENSE STICKS JAI GANESH,
$barcode = (isset($row[1]) ? $row[1] : '');
// print_r($barcode);
//OUTPUT 683988 683988 683988
$quantity = $this->input->post("Quantity" . $x . "");
// print_r($quantity);
//THE PROBLEM ARISES HERE OUTPUT COMES LIKE Quantity1 Quantity1 Quantity1
$flag = $this->cartmodel->productCategory($category);
// print_r($flag);
}
}
}
精彩评论