hello all my name is rico,
i want make some app like can combine number from input
example :
i have 4 variable like this
$num1 = 96;
$num2 = 20;
$num3 = 19;
$num4 = 37;

so how can i get the result like this
9213 9217 9293 9297 .. etc.

and example 2 if $num is empty then the result is like this
213 217 293 .. etc.

note : space in number is for star i can't write start in simbol in there

Recommended Answers

Thanks for the comment. That makes me think you need to use the following function to convert numerics to strings.

PHP is an untyped language. There's no need to type cast it to a string. Use the PHP substr() function to get the digit you want (first, last, …

Jump to Post

All 4 Replies

I can't see how any combination of the variables given results in 9213 or such. Maybe your examples were incorrect?

commented: must take 1 by 1 number from variable example like this $num1 = 9; $num2 = 2; $num3 = 1; $num4 = 3; and combine $num1.$num2.$num3.$num4 = 9213 and etc +0

Thanks for the comment. That makes me think you need to use the following function to convert numerics to strings.

PHP is an untyped language. There's no need to type cast it to a string. Use the PHP substr() function to get the digit you want (first, last, middle.)

commented: Hmm, my reading was they were making a string, not extracting. +15
commented: where i can reply my post? i want reply for the answer +0

solved the answer :

$num1 = 96;
$num2 = 20;
$num3 = 19;
$num4 = 37;

$data = [];

for ($i = 0; $i < count($num1); $i++) {
    for ($i1 = 0; $i1 < count($num2); $i1++) {
        for ($i2 = 0; $i2 < count($num3); $i2++) {
            for ($i3 = 0; $i3 < count($num4); $i3++) {
                $num = $num1[$i].$num2[$i1].$num3[$i2].$num4[$i3];
                array_push($data, $num);
            }
        }
    }
}
Be a part of the DaniWeb community

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