0
$t1='SC001';

$price = array(
            $t1 => array ('retail' => $retail)
);

I want to change $retail to be array to store more than one value

$t1='SC001';

    $price = array(
                $t1 => array ('retail' => array ($var1,$var2..........))
    );

My question is I don't know how many variable($var1 , $var2...) need to input to array, So need to use for loop to check
If $var is not null Then input to array.
But how to write this code?
Thanks~

3
Contributors
2
Replies
3
Views
4 Years
Discussion Span
Last Post by Zagga
0

@erik216

My question is I don't know how many variable($var1 , $var2...) need to input to array, So need to use for loop to check

I don't know how much variables you need so here is a link of few different kind arrays that you can used from:

http://www.tutorialspoint.com/php/php_arrays.htm

Just pick one array and plugin the data, if you still have issue from the example with your data then post your array with your data.

1

Hi erik216,

You can use array_push() to add an element to the end of an array.

Check if the value is null, if not, array_push it into your array.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.