I edited it, I misunderstood you at first. Try this one.Not as far as I'm aware.There are also simple functions, like array_merge(), but I'm not sure that's customizable enough for your current purposes.
I edited it, I misunderstood you at first. Try this one.Not as far as I'm aware.There are also simple functions, like array_merge(), but I'm not sure that's customizable enough for your current purposes.
Twey | I understand English | 日本語が分かります | mi jimpe fi le jbobau | mi esperanton komprenas | je comprends français | entiendo español | tôi ít hiểu tiếng Việt | ich verstehe ein bisschen Deutsch | beware XHTML | common coding mistakes | tutorials | various stuff | argh PHP!
Tried it, still no luck.
Although I noticed that if the first value of $id is "100" and $qty is "6"
it will print
Array ( [0] => 600 [1] => 0 [2] => 0 [3] => 0 [4] => 0 [5] => 0 )
Whereas if the first value of $id is "100" and $qty is "2"
it will print
Array ( [0] => 200 [1] => 0 )
Still looks like you're using the old code to me.
Twey | I understand English | 日本語が分かります | mi jimpe fi le jbobau | mi esperanton komprenas | je comprends français | entiendo español | tôi ít hiểu tiếng Việt | ich verstehe ein bisschen Deutsch | beware XHTML | common coding mistakes | tutorials | various stuff | argh PHP!
oops, yeah I had both in there!
The new one is much better although it prints
Array ( [0] => 100 [1] => 100 [2] => 100 [3] => 100 [4] => 100 [5] => 100 )
Which is almost what i want but without the "[0] =>"
but instead the value just seperated with commas
Array ('100','100','100','100','100','100')
That's harder because PHP doesn't output that automatically.
function array_out($a) {
echo 'Array (\'';
echo implode('\',\'',$a);
echo '\')';
}
Daniel - Freelance Web Design | <?php?> | <html>| español | Deutsch | italiano | português | català | un peu de français | some knowledge of several other languages: I can sometimes help translate here on DD | Linguistics Forum
Do you know how i'd put that in relation to this: ?
I'm assuming that i'd replace $a with $cart?PHP Code:$cart = array();
foreach($id as $k => $v)
for($i = 0; $i < $qty[$k]; ++$i)
$cart[] = $v;
e.g.
PHP Code:function array_out($cart) {
echo 'Array (\'';
echo implode('\',\'',$cart);
echo '\')';
}
Why are you printing an array like that? The string representation of an array is only meant for debugging purposes.
Twey | I understand English | 日本語が分かります | mi jimpe fi le jbobau | mi esperanton komprenas | je comprends français | entiendo español | tôi ít hiểu tiếng Việt | ich verstehe ein bisschen Deutsch | beware XHTML | common coding mistakes | tutorials | various stuff | argh PHP!
function name($argument) { ....stuff.... }
That creates a function.
For $cart, you'd use array_out($cart); and that would execute the commands in it.
Alternatively, you could just use the three lines from inside the function and replace $a in the second with $cart, as you did in the last code block (but then you don'tneed the first or last line)
Daniel - Freelance Web Design | <?php?> | <html>| español | Deutsch | italiano | português | català | un peu de français | some knowledge of several other languages: I can sometimes help translate here on DD | Linguistics Forum
Perfect, thanks once again fellas!
My final code ended up like this:
PHP Code:$temp = array();
foreach($id as $k => $v)
for($i = 0; $i < $qty[$k]; ++$i)
$temp[] = $v;
$cart = "array ('". implode("','",$temp)."')";
That confused me for a minute because it lacks brackets. I'd add them in for clarity.
foreach {
for {
...
}}
Daniel - Freelance Web Design | <?php?> | <html>| español | Deutsch | italiano | português | català | un peu de français | some knowledge of several other languages: I can sometimes help translate here on DD | Linguistics Forum
Bookmarks