Hi ! i am working this code ...basically this code using php explode to get required data like Net com-1 from this line <span class=company>Net com-1</span> here is my code: <?php $data=file_get_contents('http://www.webtjax.com/test.txt'); $line_title=explode('<span class=company>',$data); unset ($line_title[0]); foreach($line_title as $part) { $line_title_temp=explode('</span>',$part); echo $line_title_temp[0].'<br />' ; } ?> PHP: Now i successfully get the end result i have no problem ..... but i am failed in this step when i use this with 2 code like <?php $data=file_get_contents('http://www.webtjax.com/test.txt'); /////**************************************************** $line_title=explode('true);" title="',$data); unset ($line_title[0]); foreach($line_title as $part) { $line_title_temp=explode('">',$part); echo $line_title_temp[0].'<br />' ; } /////*************************************************** echo '<h1>= = = = = </h1>' ; ////**************************************************** $line_title=explode('<span class=company>',$data); unset ($line_title[0]); foreach($line_title as $part) { $line_title_temp=explode('</span>',$part); echo $line_title_temp[0].'<br />' ; } /////**************************************************** ?> PHP: this will get this result Webmaster-1 Webmaster-2 Webmaster-3 Webmaster-4 Webmaster-5 Webmaster-6 Webmaster-7 Webmaster-8 Webmaster-9 Webmaster-10 = = = = = Net com-1 Net com-2 Net com-3 Net com-4 Net com-5 Net com-6 Net com-7 Net com-8 Net com-9 Now my question is that How i can add this two variable like this But i have no idea how i can done ...?
This works <?php $data=file_get_contents('http://www.webtjax.com/test.txt'); /////**************************************************** $line_title=explode('true);" title="',$data); unset ($line_title[0]); $x = 0; foreach($line_title as $part) { $temp=explode('">',$part); $part_1[$x] = $temp[0]; $x++; } /////*************************************************** ////**************************************************** $line_title=explode('<span class=company>',$data); $x = 0; unset ($line_title[0]); foreach($line_title as $part) { $temp =explode('</span>',$part); $part_2[$x] = $temp[0]; $x++; } /////**************************************************** $y = 0; while($y <= $x) { echo $part_1[$y] ." @ ".$part_2[$y]."<br />"; $y++; } ?> PHP: But im sure there´s a better way
Thanks for this ...it realy works that i want but end result is why like that ...one is missing Webmaster-1 @ Net com-1 Webmaster-2 @ Net com-2 Webmaster-3 @ Net com-3 Webmaster-4 @ Net com-4 Webmaster-5 @ Net com-5 Webmaster-6 @ Net com-6 Webmaster-7 @ Net com-7 Webmaster-8 @ Net com-8 Webmaster-9 @ Net com-9 Webmaster-10 @