For Programmers: Free Programming Magazines  


Home > Archive > PHP Language > April 2005 > Determine foreach









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author Determine foreach
Mindy Geac

2005-04-18, 8:55 am

We are using the foreach($array as $eachline) function in an array.

No. Value.
[a] => apple
[b] => banana
[am] => monkey

How do I determine the No.varabele of the array within the foreach
function?

Mindy


srobertson

2005-04-18, 8:55 am

First step look in php manual, available for downloand from
http://www.php.net/

foreach ($yourarray as $key => $value){

echo $key .";".$value."/n"

}

the $key is the key

Hello, Mindy!
You wrote on Mon, 18 Apr 2005 13:07:16 +0200:

MG> No. Value.
MG> [a] => apple
MG> [b] => banana
MG> [am] => monkey

MG> How do I determine the No.varabele of the array within the foreach
MG> function?


Scriptdude

2005-04-18, 8:55 am

Mindy Geac wrote:
> We are using the foreach($array as $eachline) function in an array.
>
> No. Value.
> [a] => apple
> [b] => banana
> [am] => monkey
>
> How do I determine the No.varabele of the array within the foreach
> function?
>
> Mindy
>
>


<?
foreach($array AS $key => $value) {

echo 'My key is:' . $key . ' and my value is: ' . $value;

}
?>

--
___| ___| _ \ _ _| _ \__ __| __ \ | | __ \ ____|
\___ \ | | | | | | | | | | | | | __|
| | __ < | ___/ | | | | | | | |
_____/ \____|_| \_\___|_| _| ____/ \___/ ____/ _____|
Computers will never take the place of books. You can't stand on a
floppy disk to reach a high shelf.
I thought 'Deep Throat' was a movie about a giraffe :/


Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com