Jump to content

combining two array into associative array..in loop structure


diana253

Recommended Posts

[code]    
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];
}
[/code]

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~~~
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.