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
https://forums.phpfreaks.com/topic/268620-foreach-within-function-help/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.