Jump to content


Photo

combining two array into associative array..in loop structure


  • Please log in to reply
No replies to this topic

#1 diana253

diana253
  • New Members
  • Pip
  • Newbie
  • 2 posts

Posted 13 March 2006 - 05:29 PM

    
function filter($res)
{
    $y_arr="";
    $y_arr = queryYahoo("");        
    //split strings into array of 10
    $y_arr = split ("<LI>", trim($y_arr));
    $y_res = "";
    $count = count($y_arr);
    for ($i=1; $i<$count; $i++)
    {
        $y_1 = explode ("class=yschurl>",trim($y_arr[$i]));
        $y_2 = explode ("</EM>",$y_1[1]);
        $y_URL[$i] = $y_2[0];
        $y_res[$i]= $y_arr[$i].$y_URL[$i];
    }
    
   return $y_res[2];
}

imagine the search results you got from yahoo..
right now i have an array containing all the results in array format..
the $y_res[2] contains - $y_arr[2] <--- result desc
- $y_URL[2] <-- result URL

What i want to do is, i want to combine the $y_arr[] and $y_URL into one array as associative array
i've been trying to do this for about two weeks already but nothings seem to be working..
i guess maybe it's because the [$i] thing..i dont know how to do it..please help me here~~~





0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users