473,385 Members | 1,356 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

can you foreach() two arrays at once ?

Hello,
So, I was wondering how to do this:

foreach($foo as $k=>$v AND $bar as $k2=>$v2){
echo '<TR><TD>$k</TD><TD>$v</TD><TD>$k2</TD><TD>$v2</TD></TR>;
}

Thanks,
Sep 7 '07 #1
22 38477
J. Frank Parnell wrote:
Hello,
So, I was wondering how to do this:

foreach($foo as $k=>$v AND $bar as $k2=>$v2){
echo '<TR><TD>$k</TD><TD>$v</TD><TD>$k2</TD><TD>$v2</TD></TR>;
}

Thanks,
No.

However, you can use "each" to do the same thing, i.e.

reset $array1;
reset $array2;

for ((list($key1, $val1) = each($array1)) &&
(list($key2, $val2) = each($array2)) {
// $key1 and val1 contain the key and value for an element in $array1
// $key2 and val2 contain the key and value for an element in $array2
// Do your stuff here
}

It will stop as soon as you run out of elements in either array.
--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
js*******@attglobal.net
==================
Sep 7 '07 #2
On Thu, 06 Sep 2007 21:41:27 -0400, Jerry Stuckle <js*******@attglobal.net>
wrote:
>J. Frank Parnell wrote:
>Hello,
So, I was wondering how to do this:

foreach($foo as $k=>$v AND $bar as $k2=>$v2){
echo '<TR><TD>$k</TD><TD>$v</TD><TD>$k2</TD><TD>$v2</TD></TR>;
}

Thanks,

No.

However, you can use "each" to do the same thing, i.e.

reset $array1;
reset $array2;

for ((list($key1, $val1) = each($array1)) &&
(list($key2, $val2) = each($array2)) {
// $key1 and val1 contain the key and value for an element in $array1
// $key2 and val2 contain the key and value for an element in $array2
// Do your stuff here
}

It will stop as soon as you run out of elements in either array.
Ah, cool, I saw similar on the php.net. Is there a way to do it so that it will
go thru all of both, even if one runs out?

Sep 7 '07 #3
On Sep 7, 8:49 am, J. Frank Parnell <p...@edgecity.ufowrote:
On Thu, 06 Sep 2007 21:41:27 -0400, Jerry Stuckle <jstuck...@attglobal.net>
wrote:
J. Frank Parnell wrote:
Hello,
So, I was wondering how to do this:
foreach($foo as $k=>$v AND $bar as $k2=>$v2){
echo '<TR><TD>$k</TD><TD>$v</TD><TD>$k2</TD><TD>$v2</TD></TR>;
}
Thanks,
No.
However, you can use "each" to do the same thing, i.e.
reset $array1;
reset $array2;
for ((list($key1, $val1) = each($array1)) &&
(list($key2, $val2) = each($array2)) {
// $key1 and val1 contain the key and value for an element in $array1
// $key2 and val2 contain the key and value for an element in $array2
// Do your stuff here
}
It will stop as soon as you run out of elements in either array.

Ah, cool, I saw similar on the php.net. Is there a way to do it so that it will
go thru all of both, even if one runs out?

if (count ($arr1) count($arr2)) {
$len = count($arr1);
}
else {
$len = count($arr2);
}

Now

foreach($i=0; $i < $len; $i++) {

list($key1, $val1) = @each($arr1);
list($key2, $val2) = @each($arr2);
}

What about this?
I have not checked this.

http://satya61229.blogspot.com/

Sep 7 '07 #4
On Sep 7, 12:28 pm, Satya <satya61...@gmail.comwrote:
On Sep 7, 8:49 am, J. Frank Parnell <p...@edgecity.ufowrote:
On Thu, 06 Sep 2007 21:41:27 -0400, Jerry Stuckle <jstuck...@attglobal.net>
wrote:
>J. Frank Parnell wrote:
>Hello,
>So, I was wondering how to do this:
>foreach($foo as $k=>$v AND $bar as $k2=>$v2){
> echo '<TR><TD>$k</TD><TD>$v</TD><TD>$k2</TD><TD>$v2</TD></TR>;
>}
>Thanks,
>No.
>However, you can use "each" to do the same thing, i.e.
>reset $array1;
>reset $array2;
>for ((list($key1, $val1) = each($array1)) &&
(list($key2, $val2) = each($array2)) {
>// $key1 and val1 contain the key and value for an element in $array1
>// $key2 and val2 contain the key and value for an element in $array2
>// Do your stuff here
>}
>It will stop as soon as you run out of elements in either array.
Ah, cool, I saw similar on the php.net. Is there a way to do it so that it will
go thru all of both, even if one runs out?

if (count ($arr1) count($arr2)) {
$len = count($arr1);}

else {
$len = count($arr2);

}

Now

for($i=0; $i < $len; $i++) {

list($key1, $val1) = @each($arr1);
list($key2, $val2) = @each($arr2);

}

What about this?
I have not checked this.

http://satya61229.blogspot.com/
There I used "foreach" instead of "for".

Sep 7 '07 #5
J. Frank Parnell wrote:
On Thu, 06 Sep 2007 21:41:27 -0400, Jerry Stuckle <js*******@attglobal.net>
wrote:
>J. Frank Parnell wrote:
>>Hello,
So, I was wondering how to do this:

foreach($foo as $k=>$v AND $bar as $k2=>$v2){
echo '<TR><TD>$k</TD><TD>$v</TD><TD>$k2</TD><TD>$v2</TD></TR>;
}

Thanks,
No.

However, you can use "each" to do the same thing, i.e.

reset $array1;
reset $array2;

for ((list($key1, $val1) = each($array1)) &&
(list($key2, $val2) = each($array2)) {
// $key1 and val1 contain the key and value for an element in $array1
// $key2 and val2 contain the key and value for an element in $array2
// Do your stuff here
}

It will stop as soon as you run out of elements in either array.

Ah, cool, I saw similar on the php.net. Is there a way to do it so that it will
go thru all of both, even if one runs out?
What do you want to do with the array which runs out? And what do you
want to do with the array with items left?

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
js*******@attglobal.net
==================
Sep 7 '07 #6
On Fri, 07 Sep 2007 07:22:46 -0400, Jerry Stuckle <js*******@attglobal.net>
wrote:
>J. Frank Parnell wrote:
>On Thu, 06 Sep 2007 21:41:27 -0400, Jerry Stuckle <js*******@attglobal.net>
wrote:
>>J. Frank Parnell wrote:
Hello,
So, I was wondering how to do this:

foreach($foo as $k=>$v AND $bar as $k2=>$v2){
echo '<TR><TD>$k</TD><TD>$v</TD><TD>$k2</TD><TD>$v2</TD></TR>;
}

Thanks,
No.

However, you can use "each" to do the same thing, i.e.

reset $array1;
reset $array2;

for ((list($key1, $val1) = each($array1)) &&
(list($key2, $val2) = each($array2)) {
// $key1 and val1 contain the key and value for an element in $array1
// $key2 and val2 contain the key and value for an element in $array2
// Do your stuff here
}

It will stop as soon as you run out of elements in either array.

Ah, cool, I saw similar on the php.net. Is there a way to do it so that it will
go thru all of both, even if one runs out?

What do you want to do with the array which runs out? And what do you
want to do with the array with items left?
I figured the var that ran out would just be empty while the other var is still
listing, eaching, etc. It might be handy to be able to specify a default value
instead of empty, like &nbsp for the table exapmle above. Looks like I could
just stick a little if() in Satya's code.
Sep 7 '07 #7
On Fri, 07 Sep 2007 17:57:00 +0200, J. Frank Parnell <po*@edgecity.ufo
wrote:
On Fri, 07 Sep 2007 07:22:46 -0400, Jerry Stuckle
<js*******@attglobal.net>
wrote:
>J. Frank Parnell wrote:
>>On Thu, 06 Sep 2007 21:41:27 -0400, Jerry Stuckle
<js*******@attglobal.net>
wrote:

J. Frank Parnell wrote:
Hello,
So, I was wondering how to do this:
>
foreach($foo as $k=>$v AND $bar as $k2=>$v2){
echo '<TR><TD>$k</TD><TD>$v</TD><TD>$k2</TD><TD>$v2</TD></TR>;
}
>
Thanks,
No.

However, you can use "each" to do the same thing, i.e.

reset $array1;
reset $array2;

for ((list($key1, $val1) = each($array1)) &&
(list($key2, $val2) = each($array2)) {
// $key1 and val1 contain the key and value for an element in $array1
// $key2 and val2 contain the key and value for an element in $array2
// Do your stuff here
}

It will stop as soon as you run out of elements in either array.

Ah, cool, I saw similar on the php.net. Is there a way to do it so
that it will
go thru all of both, even if one runs out?

What do you want to do with the array which runs out? And what do you
want to do with the array with items left?

I figured the var that ran out would just be empty while the other var
is still
listing, eaching, etc. It might be handy to be able to specify a
default value
instead of empty, like &nbsp for the table exapmle above. Looks like I
could
just stick a little if() in Satya's code.
Or an array_pad() on the smaller one...
--
Rik Wasmus
Sep 7 '07 #8
J. Frank Parnell wrote:
On Fri, 07 Sep 2007 07:22:46 -0400, Jerry Stuckle <js*******@attglobal.net>
wrote:
>J. Frank Parnell wrote:
>>On Thu, 06 Sep 2007 21:41:27 -0400, Jerry Stuckle <js*******@attglobal.net>
wrote:

J. Frank Parnell wrote:
Hello,
So, I was wondering how to do this:
>
foreach($foo as $k=>$v AND $bar as $k2=>$v2){
echo '<TR><TD>$k</TD><TD>$v</TD><TD>$k2</TD><TD>$v2</TD></TR>;
}
>
Thanks,
No.

However, you can use "each" to do the same thing, i.e.

reset $array1;
reset $array2;

for ((list($key1, $val1) = each($array1)) &&
(list($key2, $val2) = each($array2)) {
// $key1 and val1 contain the key and value for an element in $array1
// $key2 and val2 contain the key and value for an element in $array2
// Do your stuff here
}

It will stop as soon as you run out of elements in either array.
Ah, cool, I saw similar on the php.net. Is there a way to do it so that it will
go thru all of both, even if one runs out?
What do you want to do with the array which runs out? And what do you
want to do with the array with items left?

I figured the var that ran out would just be empty while the other var is still
listing, eaching, etc. It might be handy to be able to specify a default value
instead of empty, like &nbsp for the table exapmle above. Looks like I could
just stick a little if() in Satya's code.

OK, then try this:

reset $array1;
reset $array2;

for (($val1 = each($array1)) || ($val2 = each($array2)) {
if ($val1) { // false if at the end
// $val1['key'] contains the key
// $val1['value'] contains the value
echo $val1['key'] . '=>' $val1['value'];
}
else
echo '&nbsp;';
if ($val2) { // false if at the end
// $val2['key'] contains the key
// $val2['value'] contains the value
echo $val2['key'] . '=>' $val2['value'];
}
else
echo '&nbsp;';
}
--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
js*******@attglobal.net
==================
Sep 7 '07 #9
On Fri, 07 Sep 2007 19:13:57 +0200, Jerry Stuckle
<js*******@attglobal.netwrote:
J. Frank Parnell wrote:
>On Fri, 07 Sep 2007 07:22:46 -0400, Jerry Stuckle
<js*******@attglobal.net>
wrote:
>>J. Frank Parnell wrote:
On Thu, 06 Sep 2007 21:41:27 -0400, Jerry Stuckle
<js*******@attglobal.net>
wrote:

J. Frank Parnell wrote:
>Hello,
>So, I was wondering how to do this:
>>
>foreach($foo as $k=>$v AND $bar as $k2=>$v2){
> echo '<TR><TD>$k</TD><TD>$v</TD><TD>$k2</TD><TD>$v2</TD></TR>;
>}
>>
>Thanks,
No.
>
However, you can use "each" to do the same thing, i.e.
>
reset $array1;
reset $array2;
>
for ((list($key1, $val1) = each($array1)) &&
(list($key2, $val2) = each($array2)) {
// $key1 and val1 contain the key and value for an element in $array1
// $key2 and val2 contain the key and value for an element in $array2
// Do your stuff here
}
>
It will stop as soon as you run out of elements in either array.
Ah, cool, I saw similar on the php.net. Is there a way to do it so
that it will
go thru all of both, even if one runs out?
What do you want to do with the array which runs out? And what do you
want to do with the array with items left?
I figured the var that ran out would just be empty while the other
var is still
listing, eaching, etc. It might be handy to be able to specify a
default value
instead of empty, like &nbsp for the table exapmle above. Looks likeI
could
just stick a little if() in Satya's code.

OK, then try this:

reset $array1;
reset $array2;

for (($val1 = each($array1)) || ($val2 = each($array2)) {
if ($val1) { // false if at the end
// $val1['key'] contains the key
// $val1['value'] contains the value
echo $val1['key'] . '=>' $val1['value'];
}
else
echo '&nbsp;';
if ($val2) { // false if at the end
// $val2['key'] contains the key
// $val2['value'] contains the value
echo $val2['key'] . '=>' $val2['value'];
}
else
echo '&nbsp;';
}
Hmmz, haven't tried it, but won't the second list argument only be run
when the first fails, so in essence 2 foreach loops after one another?
--
Rik Wasmus
Sep 7 '07 #10
On Fri, 07 Sep 2007 18:47:47 +0200, "Rik Wasmus" <lu************@hotmail.com>
wrote:
>On Fri, 07 Sep 2007 17:57:00 +0200, J. Frank Parnell <po*@edgecity.ufo>
wrote:
>On Fri, 07 Sep 2007 07:22:46 -0400, Jerry Stuckle
<js*******@attglobal.net>
wrote:
>>J. Frank Parnell wrote:
On Thu, 06 Sep 2007 21:41:27 -0400, Jerry Stuckle
<js*******@attglobal.net>
wrote:

J. Frank Parnell wrote:
>Hello,
>So, I was wondering how to do this:
>>
>foreach($foo as $k=>$v AND $bar as $k2=>$v2){
> echo '<TR><TD>$k</TD><TD>$v</TD><TD>$k2</TD><TD>$v2</TD></TR>;
>}
>>
>Thanks,
No.
>
However, you can use "each" to do the same thing, i.e.
>
reset $array1;
reset $array2;
>
for ((list($key1, $val1) = each($array1)) &&
(list($key2, $val2) = each($array2)) {
// $key1 and val1 contain the key and value for an element in $array1
// $key2 and val2 contain the key and value for an element in $array2
// Do your stuff here
}
>
It will stop as soon as you run out of elements in either array.

Ah, cool, I saw similar on the php.net. Is there a way to do it so
that it will
go thru all of both, even if one runs out?
What do you want to do with the array which runs out? And what do you
want to do with the array with items left?

I figured the var that ran out would just be empty while the other var
is still
listing, eaching, etc. It might be handy to be able to specify a
default value
instead of empty, like &nbsp for the table exapmle above. Looks like I
could
just stick a little if() in Satya's code.

Or an array_pad() on the smaller one...
Well, neither of these are working, Jerry's (both scripts) have a syntax error,
(missing ; and I cant figure where it wants it) and Satya's outputs:
0 Array 0 0
1 Array 1 1
2 Array 2 2
3 Array 3 3
4 4

Sep 7 '07 #11
Jerry Stuckle wrote:
J. Frank Parnell wrote:
>On Fri, 07 Sep 2007 07:22:46 -0400, Jerry Stuckle
<js*******@attglobal.net>
wrote:
>>J. Frank Parnell wrote:
On Thu, 06 Sep 2007 21:41:27 -0400, Jerry Stuckle
<js*******@attglobal.net>
wrote:

J. Frank Parnell wrote:
>Hello,
>So, I was wondering how to do this:
>>
>foreach($foo as $k=>$v AND $bar as $k2=>$v2){
> echo '<TR><TD>$k</TD><TD>$v</TD><TD>$k2</TD><TD>$v2</TD></TR>;
>}
>>
>Thanks,
No.
>
However, you can use "each" to do the same thing, i.e.
>
reset $array1;
reset $array2;
>
for ((list($key1, $val1) = each($array1)) &&
(list($key2, $val2) = each($array2)) {
// $key1 and val1 contain the key and value for an element in $array1
// $key2 and val2 contain the key and value for an element in $array2
// Do your stuff here
}
>
It will stop as soon as you run out of elements in either array.
Ah, cool, I saw similar on the php.net. Is there a way to do it so
that it will
go thru all of both, even if one runs out?
What do you want to do with the array which runs out? And what do
you want to do with the array with items left?

I figured the var that ran out would just be empty while the other
var is still
listing, eaching, etc. It might be handy to be able to specify a
default value
instead of empty, like &nbsp for the table exapmle above. Looks like
I could
just stick a little if() in Satya's code.


OK, then try this:

reset $array1;
reset $array2;

for (($val1 = each($array1)) || ($val2 = each($array2)) {
if ($val1) { // false if at the end
// $val1['key'] contains the key
// $val1['value'] contains the value
echo $val1['key'] . '=>' $val1['value'];
}
else
echo '&nbsp;';
if ($val2) { // false if at the end
// $val2['key'] contains the key
// $val2['value'] contains the value
echo $val2['key'] . '=>' $val2['value'];
}
else
echo '&nbsp;';
}

Sorry - that should be:

for (($val1 = each($array1)) || ($val2 = each($array2))) {

Missed an extra paren at the end.

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
js*******@attglobal.net
==================
Sep 7 '07 #12
Rik Wasmus wrote:
On Fri, 07 Sep 2007 19:13:57 +0200, Jerry Stuckle
<js*******@attglobal.netwrote:
>J. Frank Parnell wrote:
>>On Fri, 07 Sep 2007 07:22:46 -0400, Jerry Stuckle
<js*******@attglobal.net>
wrote:

J. Frank Parnell wrote:
On Thu, 06 Sep 2007 21:41:27 -0400, Jerry Stuckle
<js*******@attglobal.net>
wrote:
>
>J. Frank Parnell wrote:
>>Hello,
>>So, I was wondering how to do this:
>>>
>>foreach($foo as $k=>$v AND $bar as $k2=>$v2){
>> echo '<TR><TD>$k</TD><TD>$v</TD><TD>$k2</TD><TD>$v2</TD></TR>;
>>}
>>>
>>Thanks,
>No.
>>
>However, you can use "each" to do the same thing, i.e.
>>
>reset $array1;
>reset $array2;
>>
>for ((list($key1, $val1) = each($array1)) &&
> (list($key2, $val2) = each($array2)) {
>// $key1 and val1 contain the key and value for an element in $array1
>// $key2 and val2 contain the key and value for an element in $array2
>// Do your stuff here
>}
>>
>It will stop as soon as you run out of elements in either array.
Ah, cool, I saw similar on the php.net. Is there a way to do it so
that it will
go thru all of both, even if one runs out?
What do you want to do with the array which runs out? And what do
you want to do with the array with items left?
I figured the var that ran out would just be empty while the other
var is still
listing, eaching, etc. It might be handy to be able to specify a
default value
instead of empty, like &nbsp for the table exapmle above. Looks like
I could
just stick a little if() in Satya's code.

OK, then try this:

reset $array1;
reset $array2;

for (($val1 = each($array1)) || ($val2 = each($array2)) {
if ($val1) { // false if at the end
// $val1['key'] contains the key
// $val1['value'] contains the value
echo $val1['key'] . '=>' $val1['value'];
}
else
echo '&nbsp;';
if ($val2) { // false if at the end
// $val2['key'] contains the key
// $val2['value'] contains the value
echo $val2['key'] . '=>' $val2['value'];
}
else
echo '&nbsp;';
}

Hmmz, haven't tried it, but won't the second list argument only be run
when the first fails, so in essence 2 foreach loops after one another?

Nope, both if statements are in the loop. Each time through it will
process $val1 then $val2.

Your suggestion of array_pad() is also good, unless the arrays are large.

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
js*******@attglobal.net
==================
Sep 7 '07 #13
On Fri, 07 Sep 2007 15:01:24 -0400, Jerry Stuckle <js*******@attglobal.net>
wrote:
>Jerry Stuckle wrote:
>J. Frank Parnell wrote:
>>On Fri, 07 Sep 2007 07:22:46 -0400, Jerry Stuckle
<js*******@attglobal.net>
wrote:

J. Frank Parnell wrote:
On Thu, 06 Sep 2007 21:41:27 -0400, Jerry Stuckle
<js*******@attglobal.net>
wrote:
>
>J. Frank Parnell wrote:
>>Hello,
reset $array1;
reset $array2;

for (($val1 = each($array1)) || ($val2 = each($array2)) {
if ($val1) { // false if at the end
// $val1['key'] contains the key
// $val1['value'] contains the value
echo $val1['key'] . '=>' $val1['value'];
}
else
echo '&nbsp;';
if ($val2) { // false if at the end
// $val2['key'] contains the key
// $val2['value'] contains the value
echo $val2['key'] . '=>' $val2['value'];
}
else
echo '&nbsp;';
}


Sorry - that should be:

for (($val1 = each($array1)) || ($val2 = each($array2))) {

Missed an extra paren at the end.
Thanks again for the help, however, I still get:
Parse error: syntax error, unexpected ')', expecting ';' in
/web/sites/asdf/asdf.com/_impexp/test.php on line 55

Isnt there supposed to be 3 expressions in a FOR? I tried with semicolons here
and there, but couldnt get it.

current code:
for (($val1 = each($users)) || ($val2 = each($newusers))) {
if ($val1) { // false if at the end
// $val1['key'] contains the key
// $val1['value'] contains the value
echo $val1['key'] . '=>' $val1['value'];
}
else
echo '&nbsp;';
if ($val2) { // false if at the end
// $val2['key'] contains the key
// $val2['value'] contains the value
echo $val2['key'] . '=>' $val2['value'];
}
else
echo '&nbsp;';
}

Sep 7 '07 #14
J. Frank Parnell wrote:
On Fri, 07 Sep 2007 15:01:24 -0400, Jerry Stuckle <js*******@attglobal.net>
wrote:
>Jerry Stuckle wrote:
>>J. Frank Parnell wrote:
On Fri, 07 Sep 2007 07:22:46 -0400, Jerry Stuckle
<js*******@attglobal.net>
wrote:

J. Frank Parnell wrote:
>On Thu, 06 Sep 2007 21:41:27 -0400, Jerry Stuckle
><js*******@attglobal.net>
>wrote:
>>
>>J. Frank Parnell wrote:
>>>Hello,
reset $array1;
reset $array2;

for (($val1 = each($array1)) || ($val2 = each($array2)) {
if ($val1) { // false if at the end
// $val1['key'] contains the key
// $val1['value'] contains the value
echo $val1['key'] . '=>' $val1['value'];
}
else
echo '&nbsp;';
if ($val2) { // false if at the end
// $val2['key'] contains the key
// $val2['value'] contains the value
echo $val2['key'] . '=>' $val2['value'];
}
else
echo '&nbsp;';
}

Sorry - that should be:

for (($val1 = each($array1)) || ($val2 = each($array2))) {

Missed an extra paren at the end.

Thanks again for the help, however, I still get:
Parse error: syntax error, unexpected ')', expecting ';' in
/web/sites/asdf/asdf.com/_impexp/test.php on line 55

Isnt there supposed to be 3 expressions in a FOR? I tried with semicolons here
and there, but couldnt get it.

current code:
for (($val1 = each($users)) || ($val2 = each($newusers))) {
if ($val1) { // false if at the end
// $val1['key'] contains the key
// $val1['value'] contains the value
echo $val1['key'] . '=>' $val1['value'];
}
else
echo '&nbsp;';
if ($val2) { // false if at the end
// $val2['key'] contains the key
// $val2['value'] contains the value
echo $val2['key'] . '=>' $val2['value'];
}
else
echo '&nbsp;';
}
Sorry - it should be a 'while' loop, not a 'for' loop.

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
js*******@attglobal.net
==================
Sep 7 '07 #15
On Fri, 07 Sep 2007 21:03:26 +0200, Jerry Stuckle
<js*******@attglobal.netwrote:
Rik Wasmus wrote:
>On Fri, 07 Sep 2007 19:13:57 +0200, Jerry Stuckle
<js*******@attglobal.netwrote:
>>J. Frank Parnell wrote:
On Fri, 07 Sep 2007 07:22:46 -0400, Jerry Stuckle
<js*******@attglobal.net>
wrote:

J. Frank Parnell wrote:
>On Thu, 06 Sep 2007 21:41:27 -0400, Jerry Stuckle
><js*******@attglobal.net>
>wrote:
>>
>>J. Frank Parnell wrote:
>>>Hello,
>>>So, I was wondering how to do this:
>>>>
>>>foreach($foo as $k=>$v AND $bar as $k2=>$v2){
>>> echo '<TR><TD>$k</TD><TD>$v</TD><TD>$k2</TD><TD>$v2</TD></TR>;
>>>}
>>>>
>>>Thanks,
>>No.
>>>
>>However, you can use "each" to do the same thing, i.e.
>>>
>>reset $array1;
>>reset $array2;
>>>
>>for ((list($key1, $val1) = each($array1)) &&
>> (list($key2, $val2) = each($array2)) {
>>// $key1 and val1 contain the key and value for an element in
>>$array1
>>// $key2 and val2 contain the key and value for an element in
>>$array2
>>// Do your stuff here
>>}
>>>
>>It will stop as soon as you run out of elements in either array.
>Ah, cool, I saw similar on the php.net. Is there a way to do it so
>that it will
>go thru all of both, even if one runs out?
What do you want to do with the array which runs out? And what do
you want to do with the array with items left?
I figured the var that ran out would just be empty while the other
var is still
listing, eaching, etc. It might be handy to be able to specify a
default value
instead of empty, like &nbsp for the table exapmle above. Looks like
I could
just stick a little if() in Satya's code.
OK, then try this:

reset $array1;
reset $array2;

for (($val1 = each($array1)) || ($val2 = each($array2)) {
if ($val1) { // false if at the end
// $val1['key'] contains the key
// $val1['value'] contains the value
echo $val1['key'] . '=>' $val1['value'];
}
else
echo '&nbsp;';
if ($val2) { // false if at the end
// $val2['key'] contains the key
// $val2['value'] contains the value
echo $val2['key'] . '=>' $val2['value'];
}
else
echo '&nbsp;';
}
Hmmz, haven't tried it, but won't the second list argument only be run
when the first fails, so in essence 2 foreach loops after one another?

Nope, both if statements are in the loop. Each time through it will
process $val1 then $val2.
<?php
$a = $b = array();
for($i = 1;$i<5;$i++){
$a[] = 'a'.$i;
$b[] = 'b'.$i;
}
while(($val1 = each($a)) || ($val2 = each($b))){
if (isset($val1) && $val1) { // false if at the end
// $val1['key'] contains the key
// $val1['value'] contains the value
var_dump($val1);
}
else
echo 'a not set';
if (isset($val2) && $val2) { // false if at the end
// $val2['key'] contains the key
// $val2['value'] contains the value
var_dump($val2);
}
else
echo 'b not set';
}
?>
Output:
array(4) {
[1]=>
string(2) "a1"
["value"]=>
string(2) "a1"
[0]=>
int(0)
["key"]=>
int(0)
}
b not setarray(4) {
[1]=>
string(2) "a2"
["value"]=>
string(2) "a2"
[0]=>
int(1)
["key"]=>
int(1)
}
b not setarray(4) {
[1]=>
string(2) "a3"
["value"]=>
string(2) "a3"
[0]=>
int(2)
["key"]=>
int(2)
}
b not setarray(4) {
[1]=>
string(2) "a4"
["value"]=>
string(2) "a4"
[0]=>
int(3)
["key"]=>
int(3)
}
b not seta not setarray(4) {
[1]=>
string(2) "b1"
["value"]=>
string(2) "b1"
[0]=>
int(0)
["key"]=>
int(0)
}
a not setarray(4) {
[1]=>
string(2) "b2"
["value"]=>
string(2) "b2"
[0]=>
int(1)
["key"]=>
int(1)
}
a not setarray(4) {
[1]=>
string(2) "b3"
["value"]=>
string(2) "b3"
[0]=>
int(2)
["key"]=>
int(2)
}
a not setarray(4) {
[1]=>
string(2) "b4"
["value"]=>
string(2) "b4"
[0]=>
int(3)
["key"]=>
int(3)
}

So, the original argument still stands: the second expression will not be
evaluated in this conditional as long as the first will return true.
--
Rik Wasmus
Sep 8 '07 #16
Rik Wasmus wrote:
On Fri, 07 Sep 2007 21:03:26 +0200, Jerry Stuckle
<js*******@attglobal.netwrote:
>Rik Wasmus wrote:
>>On Fri, 07 Sep 2007 19:13:57 +0200, Jerry Stuckle
<js*******@attglobal.netwrote:

J. Frank Parnell wrote:
On Fri, 07 Sep 2007 07:22:46 -0400, Jerry Stuckle
<js*******@attglobal.net>
wrote:
>
>J. Frank Parnell wrote:
>>On Thu, 06 Sep 2007 21:41:27 -0400, Jerry Stuckle
>><js*******@attglobal.net>
>>wrote:
>>>
>>>J. Frank Parnell wrote:
>>>>Hello,
>>>>So, I was wondering how to do this:
>>>>>
>>>>foreach($foo as $k=>$v AND $bar as $k2=>$v2){
>>>> echo '<TR><TD>$k</TD><TD>$v</TD><TD>$k2</TD><TD>$v2</TD></TR>;
>>>>}
>>>>>
>>>>Thanks,
>>>No.
>>>>
>>>However, you can use "each" to do the same thing, i.e.
>>>>
>>>reset $array1;
>>>reset $array2;
>>>>
>>>for ((list($key1, $val1) = each($array1)) &&
>>> (list($key2, $val2) = each($array2)) {
>>>// $key1 and val1 contain the key and value for an element in
>>>$array1
>>>// $key2 and val2 contain the key and value for an element in
>>>$array2
>>>// Do your stuff here
>>>}
>>>>
>>>It will stop as soon as you run out of elements in either array.
>>Ah, cool, I saw similar on the php.net. Is there a way to do it
>>so that it will
>>go thru all of both, even if one runs out?
>What do you want to do with the array which runs out? And what do
>you want to do with the array with items left?
I figured the var that ran out would just be empty while the
other var is still
listing, eaching, etc. It might be handy to be able to specify a
default value
instead of empty, like &nbsp for the table exapmle above. Looks
like I could
just stick a little if() in Satya's code.
>

OK, then try this:

reset $array1;
reset $array2;

for (($val1 = each($array1)) || ($val2 = each($array2)) {
if ($val1) { // false if at the end
// $val1['key'] contains the key
// $val1['value'] contains the value
echo $val1['key'] . '=>' $val1['value'];
}
else
echo '&nbsp;';
if ($val2) { // false if at the end
// $val2['key'] contains the key
// $val2['value'] contains the value
echo $val2['key'] . '=>' $val2['value'];
}
else
echo '&nbsp;';
}
Hmmz, haven't tried it, but won't the second list argument only be
run when the first fails, so in essence 2 foreach loops after one
another?

Nope, both if statements are in the loop. Each time through it will
process $val1 then $val2.

<?php
$a = $b = array();
for($i = 1;$i<5;$i++){
$a[] = 'a'.$i;
$b[] = 'b'.$i;
}
while(($val1 = each($a)) || ($val2 = each($b))){
if (isset($val1) && $val1) { // false if at the end
// $val1['key'] contains the key
// $val1['value'] contains the value
var_dump($val1);
}
else
echo 'a not set';
if (isset($val2) && $val2) { // false if at the end
// $val2['key'] contains the key
// $val2['value'] contains the value
var_dump($val2);
}
else
echo 'b not set';
}
?>
Output:
array(4) {
[1]=>
string(2) "a1"
["value"]=>
string(2) "a1"
[0]=>
int(0)
["key"]=>
int(0)
}
b not setarray(4) {
[1]=>
string(2) "a2"
["value"]=>
string(2) "a2"
[0]=>
int(1)
["key"]=>
int(1)
}
b not setarray(4) {
[1]=>
string(2) "a3"
["value"]=>
string(2) "a3"
[0]=>
int(2)
["key"]=>
int(2)
}
b not setarray(4) {
[1]=>
string(2) "a4"
["value"]=>
string(2) "a4"
[0]=>
int(3)
["key"]=>
int(3)
}
b not seta not setarray(4) {
[1]=>
string(2) "b1"
["value"]=>
string(2) "b1"
[0]=>
int(0)
["key"]=>
int(0)
}
a not setarray(4) {
[1]=>
string(2) "b2"
["value"]=>
string(2) "b2"
[0]=>
int(1)
["key"]=>
int(1)
}
a not setarray(4) {
[1]=>
string(2) "b3"
["value"]=>
string(2) "b3"
[0]=>
int(2)
["key"]=>
int(2)
}
a not setarray(4) {
[1]=>
string(2) "b4"
["value"]=>
string(2) "b4"
[0]=>
int(3)
["key"]=>
int(3)
}

So, the original argument still stands: the second expression will not
be evaluated in this conditional as long as the first will return true.
Darn, you're right - I've been in vbscript too much recently (don't ask!
:-)). And it evaluates the entire expression.

Better would be:

for ($val1 = each($a), $val2 = each($b); $val1 || $val2;
$val1 = each($a), $val2 = each($b))

Does that make you happy? :-)

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
js*******@attglobal.net
==================
Sep 8 '07 #17
Jerry Stuckle wrote:
J. Frank Parnell wrote:
>On Fri, 07 Sep 2007 15:01:24 -0400, Jerry Stuckle
<js*******@attglobal.net>
wrote:
>>Jerry Stuckle wrote:
J. Frank Parnell wrote:
On Fri, 07 Sep 2007 07:22:46 -0400, Jerry Stuckle
<js*******@attglobal.net>
wrote:
>
>J. Frank Parnell wrote:
>>On Thu, 06 Sep 2007 21:41:27 -0400, Jerry Stuckle
>><js*******@attglobal.net>
>>wrote:
>>>
>>>J. Frank Parnell wrote:
>>>>Hello,
reset $array1;
reset $array2;

for (($val1 = each($array1)) || ($val2 = each($array2)) {
if ($val1) { // false if at the end
// $val1['key'] contains the key
// $val1['value'] contains the value
echo $val1['key'] . '=>' $val1['value'];
}
else
echo '&nbsp;';
if ($val2) { // false if at the end
// $val2['key'] contains the key
// $val2['value'] contains the value
echo $val2['key'] . '=>' $val2['value'];
}
else
echo '&nbsp;';
}
Sorry - that should be:

for (($val1 = each($array1)) || ($val2 = each($array2))) {

Missed an extra paren at the end.

Thanks again for the help, however, I still get:
Parse error: syntax error, unexpected ')', expecting ';' in
/web/sites/asdf/asdf.com/_impexp/test.php on line 55

Isnt there supposed to be 3 expressions in a FOR? I tried with
semicolons here
and there, but couldnt get it.
current code:
for (($val1 = each($users)) || ($val2 = each($newusers))) {
if ($val1) { // false if at the end
// $val1['key'] contains the key
// $val1['value'] contains the value
echo $val1['key'] . '=>' $val1['value'];
}
else
echo '&nbsp;';
if ($val2) { // false if at the end
// $val2['key'] contains the key
// $val2['value'] contains the value
echo $val2['key'] . '=>' $val2['value'];
}
else
echo '&nbsp;';
}

Sorry - it should be a 'while' loop, not a 'for' loop.
Also, see the correction above in response to Rik's comments:

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
js*******@attglobal.net
==================
Sep 8 '07 #18
J. Frank Parnell wrote:
Hello,
So, I was wondering how to do this:

foreach($foo as $k=>$v AND $bar as $k2=>$v2){
echo '<TR><TD>$k</TD><TD>$v</TD><TD>$k2</TD><TD>$v2</TD></TR>;
}
try

$a = array('a1' =1, 'a2' =2);
$b = array('b1' =11, 'b2' =22, 'c2' =33);

$keys = array_map(null, array_keys($a), array_keys($b));

foreach($keys as $k) {
list($k1, $k2) = $k;
$v1 = isset($k1) ? $a[$k1] : null;
$v2 = isset($k2) ? $b[$k2] : null;
echo "$k1 - $v1 - $k2 - $v2 \n";
}

if you don't need keys, this can be simplified to

foreach(array_map(null, $a, $b) as $v) {
list($v1, $v2) = $v;
echo "$v1 - $v2 \n";
}
--
gosha bine

extended php parser ~ http://code.google.com/p/pihipi
blok ~ http://www.tagarga.com/blok
Sep 8 '07 #19
On Fri, 07 Sep 2007 21:34:22 -0400, Jerry Stuckle <js*******@attglobal.net>
wrote:
>Jerry Stuckle wrote:
>J. Frank Parnell wrote:
>>On Fri, 07 Sep 2007 15:01:24 -0400, Jerry Stuckle
<js*******@attglobal.net>
wrote:

Jerry Stuckle wrote:
J. Frank Parnell wrote:
>On Fri, 07 Sep 2007 07:22:46 -0400, Jerry Stuckle
><js*******@attglobal.net>
>wrote:
>>
>>J. Frank Parnell wrote:
>>>On Thu, 06 Sep 2007 21:41:27 -0400, Jerry Stuckle
>>><js*******@attglobal.net>
>>>wrote:
>>>>
>>>>J. Frank Parnell wrote:
>>>>>Hello,
reset $array1;
reset $array2;
>
for (($val1 = each($array1)) || ($val2 = each($array2)) {
if ($val1) { // false if at the end
// $val1['key'] contains the key
// $val1['value'] contains the value
echo $val1['key'] . '=>' $val1['value'];
}
else
echo '&nbsp;';
if ($val2) { // false if at the end
// $val2['key'] contains the key
// $val2['value'] contains the value
echo $val2['key'] . '=>' $val2['value'];
}
else
echo '&nbsp;';
}
>
>
Sorry - that should be:

for (($val1 = each($array1)) || ($val2 = each($array2))) {

Missed an extra paren at the end.

Thanks again for the help, however, I still get:
Parse error: syntax error, unexpected ')', expecting ';' in
/web/sites/asdf/asdf.com/_impexp/test.php on line 55

Isnt there supposed to be 3 expressions in a FOR? I tried with
semicolons here
and there, but couldnt get it.
current code:
for (($val1 = each($users)) || ($val2 = each($newusers))) {
if ($val1) { // false if at the end
// $val1['key'] contains the key
// $val1['value'] contains the value
echo $val1['key'] . '=>' $val1['value'];
}
else
echo '&nbsp;';
if ($val2) { // false if at the end
// $val2['key'] contains the key
// $val2['value'] contains the value
echo $val2['key'] . '=>' $val2['value'];
}
else
echo '&nbsp;';
}

Sorry - it should be a 'while' loop, not a 'for' loop.

Also, see the correction above in response to Rik's comments:
OK, got it thanks. Everybody, Rik, Jerry, Gosha and Satya...I appreciate it.

Now, I go to test things and of course, I forgot one big detail. The two arrays
are actually multidimensional themselves:
$a[0] = array('a[0]key1' ='a[0]val1', 'a[0]key2' ='a[0]val2');
$a[1] = array('a[1]key1' ='a[1]val1', 'a[1]key2' ='a[1]val2');
$b[0] = array('b[0]key1' ='b[0]val1', 'b[0]key2' ='b[0]val2', 'b[0]key3' =>
'b[0]val3');
$b[1] = array('b[1]key1' ='b[1]val1', 'b[1]key2' ='b[1]val2', 'b[1]key3' =>
'b[1]val3');
$b[2] = array('b[2]key1' ='b[2]val1', 'b[2]key2' ='b[2]val2', 'b[2]key3' =>
'b[2]val3');

More like that. $a and $b are db results (arrays). Each element has its own
array of feild=>value.

I tried a couple things, nesting those scripts inside each other, but to no
avail.

Sep 11 '07 #20
J. Frank Parnell wrote:
On Fri, 07 Sep 2007 21:34:22 -0400, Jerry Stuckle <js*******@attglobal.net>
wrote:
>Jerry Stuckle wrote:
>>J. Frank Parnell wrote:
On Fri, 07 Sep 2007 15:01:24 -0400, Jerry Stuckle
<js*******@attglobal.net>
wrote:

Jerry Stuckle wrote:
>J. Frank Parnell wrote:
>>On Fri, 07 Sep 2007 07:22:46 -0400, Jerry Stuckle
>><js*******@attglobal.net>
>>wrote:
>>>
>>>J. Frank Parnell wrote:
>>>>On Thu, 06 Sep 2007 21:41:27 -0400, Jerry Stuckle
>>>><js*******@attglobal.net>
>>>>wrote:
>>>>>
>>>>>J. Frank Parnell wrote:
>>>>>>Hello,
>reset $array1;
>reset $array2;
>>
>for (($val1 = each($array1)) || ($val2 = each($array2)) {
> if ($val1) { // false if at the end
> // $val1['key'] contains the key
> // $val1['value'] contains the value
> echo $val1['key'] . '=>' $val1['value'];
> }
> else
> echo '&nbsp;';
> if ($val2) { // false if at the end
> // $val2['key'] contains the key
> // $val2['value'] contains the value
> echo $val2['key'] . '=>' $val2['value'];
> }
> else
> echo '&nbsp;';
>}
>>
>>
Sorry - that should be:
>
for (($val1 = each($array1)) || ($val2 = each($array2))) {
>
Missed an extra paren at the end.
Thanks again for the help, however, I still get:
Parse error: syntax error, unexpected ')', expecting ';' in
/web/sites/asdf/asdf.com/_impexp/test.php on line 55

Isnt there supposed to be 3 expressions in a FOR? I tried with
semicolons here
and there, but couldnt get it.
current code:
for (($val1 = each($users)) || ($val2 = each($newusers))) {
if ($val1) { // false if at the end
// $val1['key'] contains the key
// $val1['value'] contains the value
echo $val1['key'] . '=>' $val1['value'];
}
else
echo '&nbsp;';
if ($val2) { // false if at the end
// $val2['key'] contains the key
// $val2['value'] contains the value
echo $val2['key'] . '=>' $val2['value'];
}
else
echo '&nbsp;';
}

Sorry - it should be a 'while' loop, not a 'for' loop.
Also, see the correction above in response to Rik's comments:

OK, got it thanks. Everybody, Rik, Jerry, Gosha and Satya...I appreciate it.

Now, I go to test things and of course, I forgot one big detail. The two arrays
are actually multidimensional themselves:
$a[0] = array('a[0]key1' ='a[0]val1', 'a[0]key2' ='a[0]val2');
$a[1] = array('a[1]key1' ='a[1]val1', 'a[1]key2' ='a[1]val2');
$b[0] = array('b[0]key1' ='b[0]val1', 'b[0]key2' ='b[0]val2', 'b[0]key3' =>
'b[0]val3');
$b[1] = array('b[1]key1' ='b[1]val1', 'b[1]key2' ='b[1]val2', 'b[1]key3' =>
'b[1]val3');
$b[2] = array('b[2]key1' ='b[2]val1', 'b[2]key2' ='b[2]val2', 'b[2]key3' =>
'b[2]val3');

More like that. $a and $b are db results (arrays). Each element has its own
array of feild=>value.

I tried a couple things, nesting those scripts inside each other, but to no
avail.
So, what is it exactly you want?

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
js*******@attglobal.net
==================
Sep 11 '07 #21
On Mon, 10 Sep 2007 21:13:34 -0400, Jerry Stuckle <js*******@attglobal.net>
wrote:

>Now, I go to test things and of course, I forgot one big detail. The two arrays
are actually multidimensional themselves:
$a[0] = array('a[0]key1' ='a[0]val1', 'a[0]key2' ='a[0]val2');
$a[1] = array('a[1]key1' ='a[1]val1', 'a[1]key2' ='a[1]val2');
$b[0] = array('b[0]key1' ='b[0]val1', 'b[0]key2' ='b[0]val2', 'b[0]key3' =>
'b[0]val3');
$b[1] = array('b[1]key1' ='b[1]val1', 'b[1]key2' ='b[1]val2', 'b[1]key3' =>
'b[1]val3');
$b[2] = array('b[2]key1' ='b[2]val1', 'b[2]key2' ='b[2]val2', 'b[2]key3' =>
'b[2]val3');

More like that. $a and $b are db results (arrays). Each element has its own
array of feild=>value.

I tried a couple things, nesting those scripts inside each other, but to no
avail.

So, what is it exactly you want?
Same as before, go through each array, for each element, list all the
key=>values for both:
$a[0][key]-val -- $b[0][key]-val
// etc for all key-vals in $a[0] and $b[0]
$a[1][key]-val -- $b[1][key]-val
//etc
Sep 11 '07 #22
J. Frank Parnell wrote:
On Mon, 10 Sep 2007 21:13:34 -0400, Jerry Stuckle <js*******@attglobal.net>
wrote:

>>Now, I go to test things and of course, I forgot one big detail. The two arrays
are actually multidimensional themselves:
$a[0] = array('a[0]key1' ='a[0]val1', 'a[0]key2' ='a[0]val2');
$a[1] = array('a[1]key1' ='a[1]val1', 'a[1]key2' ='a[1]val2');
$b[0] = array('b[0]key1' ='b[0]val1', 'b[0]key2' ='b[0]val2', 'b[0]key3' =>
'b[0]val3');
$b[1] = array('b[1]key1' ='b[1]val1', 'b[1]key2' ='b[1]val2', 'b[1]key3' =>
'b[1]val3');
$b[2] = array('b[2]key1' ='b[2]val1', 'b[2]key2' ='b[2]val2', 'b[2]key3' =>
'b[2]val3');

More like that. $a and $b are db results (arrays). Each element has its own
array of feild=>value.

I tried a couple things, nesting those scripts inside each other, but to no
avail.
So, what is it exactly you want?

Same as before, go through each array, for each element, list all the
key=>values for both:
$a[0][key]-val -- $b[0][key]-val
// etc for all key-vals in $a[0] and $b[0]
$a[1][key]-val -- $b[1][key]-val
//etc

OK, so just create an inner loop similar to the existing one, which goes
through each of the elements in the arrays.

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
js*******@attglobal.net
==================
Sep 11 '07 #23

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
by: Bart Nessux | last post by:
How is this done in php? I've tried several variations of the following: contact_array = ($_POST, $_POST, $_POST, $_POST, $_POST); The ultimate goal is to insert the array into a table in...
35
by: Troll | last post by:
Hi, I need to write a script which reads some data and reports the findings. Just to give you an idea the structure is similar to the following. Data input example: HEADING 1 **********...
4
by: Niall | last post by:
Ok, maybe this is getting too lazy and too demanding, but hey, I thought I'd see what people thought about it. Would anyone else find a syntax like: foreach (string Name in CompanyNames and...
32
by: Joe Rattz | last post by:
Hmmm, I wrote the following code. I want an array of bools and I want to intialize them to false. bool bits = new bool; foreach(bool bit in bits) { bit = false; } The compiler complains...
7
by: David Veeneman | last post by:
This is a very simple question, but for moe reason I can't find an answer. Do I take a performance hit if a foreach statement has to evaluate an expression? For example, consider the following:...
2
by: assgar | last post by:
Hi Developemnt on win2003 server. Final server will be linux Apache,Mysql and PHP is being used. I use 2 scripts(form and process). The form displays multiple dynamic rows with chechboxs,...
6
by: Robert Bravery | last post by:
Hi all, Can some one show me how to achieve a cross product of arrays. So that if I had two arrays (could be any number) with three elements in each (once again could be any number) I would get:...
3
by: Akira | last post by:
I noticed that using foreach is much slower than using for-loop, so I want to change our current code from foreach to for-loop. But I can't figure out how. Could someone help me please? Current...
110
by: fjm | last post by:
For some reason, I have always had a hard time understanding arrays as they pertain to php and databases. I understand associative arrays just fine but when there are multidimensional arrays, I kinda...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.