array element not being traced by conditional statements but
Posted: Thu Mar 01, 2012 12:34 am
I'm not able to trace 'not out' string with conditional statement. Instead it is not being even traced by array search methods. But I can find the element when I print it like
when I try to trace it by conditional statements I fail to extract it. All I wanna do is to return those batsmen name who are not out.
thanks in advance 
Code: Select all
var_dump($sections[7][5]);Code: Select all
<?php
ob_start();
$url = 'http://m.cricbuzz.com/cricket-archive/scorecard/10777/1';
$dom = new DOMDocument;
@$dom->loadHTMLFile($url);
$tds = $dom->getElementsByTagName('td');
foreach ($tds as $td)
{
echo $td->nodeValue, PHP_EOL;
}
$page = ob_get_contents();
ob_end_flush();
$fp = fopen("output.html","w");
fwrite($fp,$page);
fclose($fp);
$pieces = explode("Bowler", file_get_contents('output.html', FILE_IGNORE_NEW_LINES));
$zaq = explode("\n", $pieces[0]);
unset($zaq[0],$zaq[1],$zaq[2],$zaq[3],$zaq[4]);
for($i=0;$i<count($zaq);$i++)
{
if ($zaq[$i]=='') { unset($zaq[$i]); echo 'reached here.. '; }
}
foreach($zaq as $value)
{
echo '<br>the next elemnt is.. '.$value.'<br>';
}
$sections = array_chunk($zaq, 6);
var_dump($sections[7][5]);
echo array_search('not out', $sections);
print_r(array_values($sections));
print_r(array_keys($sections));
echo array_key_exists('not out', $search_array);
for($i=0;$i<count($zaq);$i++)
{
echo $sections[$i][5].'<br>..';
echo count($sections[$i][5]);
$as=count($sections[$i][5]);
if($sections[$i][5]==="'not out")
{
echo count($sections[$i][5]);
echo $sections[$i][5];
var_dump($sections[$i][5]);
}
}
?>