tags:

views:

62

answers:

4

I have an array:

array(3) {
    [0]=>  string(1) "3"
    [1]=>  string(3) "488"
    [2]=>  string(3) "177"
}

I want to have a foreach for its values, which returns the number in the array. How can I do that?

+1  A: 

Here is the PHP doc

http://php.net/manual/en/control-structures.foreach.php

The code would look like

foreach ($array as $value) {
    echo "Value: $value<br />\n";
}
Codemwnci
A: 

By numbers do you mean the strings?

var_dump(array_values($your_array));
tandu
A: 
foreach ( $array as $value ) {
    echo $value;
}

You can find more about foreach here.

Ondrej Slinták
+2  A: 

I sure hope I understood your question..

foreach ($yourArray as $value)
{
    // ...
}

// OR

foreach ($yourArray as $key => $value)
{
    // ...
}

You can extract values and keys with array_values() and array_keys().

dr Hannibal Lecter