Re: Going through 2 arrays at once
| From: | Adam Zey | Date: | Tue, 23 May 2006 22:40:24 +0000 |
| Subject: | Re: Going through 2 arrays at once | ||
| References: | 1 | Groups: | php.general php.general |
| Request: | Send a blank email to php-general+get-236780@lists.php.net to get a copy of this message | ||
Pavleck, Jeremy D. wrote:
Greetings, PHP Rookie here with a quick question - how do I go through 2 arrays at once with different keys? I'd like to combine these 2 arrays into one: for ( $i = 0; $i < sizeof($logicalDrive); $i++) {It sounds like you want to use a while loop and then iterate manually through both arrays, iterating both arrays once per loop iteration. Sorry if I've misunderstood the problem. Regards, Adam Zey.echo "$arrLogDrive[$i]<br />\n"; }for (reset($logicalDrive); $i = key($logicalDrive); next($logicalDrive)) {echo "$i: $logicalDrive[$i]<br />\n";} The first array returns things that the OID in the second array represent. I.E. $array = array( 1=> 'Controller Index:', 'Drive Index:', Fault Tolerant Mode:', etc, etc); While the second has the MIB name as the key, then the return value of the snmpget: CPQIDA-MIB::cpqDaLogDrvCntlrIndex.0.1: 0 CPQIDA-MIB::cpqDaLogDrvIndex.0.1: 1 CPQIDA-MIB::cpqDaLogDrvFaultTol.0.1: mirroring What I'd like to do it replace CPQIDA-MIB::cpqDaLogDrvCntlrIndex.0.1 that gets displayed into the "Controller Index:" in the other array. I hope this makes sense. Sorry if it's super simple to solve, but I tried a few things, and googled a few things, but I must have not found the right thing I was looking for, as I still can't figure it out. Thank you very much! JDP Jeremy Pavleck Network Engineer - Systems Management IT Networks and InfrastructureDirect Line: 612-977-5881 Toll Free: 1-888-CAPELLA ext. 5881 Fax: 612-977-5053 E-mail: jeremy.pavleck@capella.edu <mailto:jeremy.pavleck@capella.edu> Capella University 225 South 6th Street, 9th Floor Minneapolis, MN 55402 www.capella.edu <http://www.capella.edu/>