tags:

views:

44

answers:

2

// I am working on matching the individual words from array $frequency // to the search results from that individual word.

I don't know why this does not work

for ($i = 1; $i <= ($frequency); $i++) {

    echo $i;


    echo getphp_AlexVortaro ($frequency[$i]);
    echo getphp_Smartfm($frequency[$i]);
    print_r($frequency[$i]);


}

I get

Notice: Undefined offset: 11 in /Users/briancarpenter/Sites/Vortoj/countplus.php

on line 21

X A lot

+3  A: 

PHP array subscripts start at 0, not 1. You want your loop to be

for ($i = 0; $i < count($frequency); $i++) { ...

Vanessa MacDougal
+1  A: 

Two things: (1) Arrays are 0-based, not 1-based. (2) Your conditional needs to use the count() function.

for ($i = 0; $i < count($frequency); $i++)
John Kugelman