Jump to content

foreach within function help


deadliver

Recommended Posts

$Stats_Cats = array("Battles","Victories","Defeats");

$Stats = array();


function GetStats($curlstr){
  
    foreach($CategoriesMajor as $key =>$value)
    {
       
[s]  $str = '<td class=""> '.$value.': </td>';	
  $str = get_part($curlstr,$str,'</tr>');  
               $str = get_part($str,'<td class="td-number-nowidth">','</td>');   
               $str = preg_replace ( "'<[^>]+>'U", "", $str);
               $str = strip_tags($str);[/s]
      //add value to the item in the array
   
      $Stats[$value]=$str;
}
  return $Stats;
}
//$string is my return from a web scrape using curl library
GetStats($string);

 

When I test this foreach loop outside of this function it works fine.

When I embed it into the function and call it, it does not begin the loop.

I am not concerned about the code inside the foreach statement since it has

yet to even try to loop.

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.