$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~

Member Avatar for LastMitch

@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.

Member Avatar for Zagga

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.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.