Witam
mam mały problem chcę z strony(jest to katalog firm) kartuzy.info/index.php?m=1&prc=0 wyciągnąć dane takie jak
nazwa firmy
tel
adres
tylko jest jeden mały problem nie każda firma ma podany numer tel, i jak niema jakaś firma numeru telefonu podane to przepisuje z niższej firmy
<?php
function filtr($text){
$text = str_replace ('
‘, ‘’, $text); $text = str_replace (’
‘, ‘’, $text); $text = str_replace (’
‘, ‘’, $text); $text = str_replace (’
’ , ‘’, $text); $text = str_replace (’
‘, ‘’, $text); $text = str_replace (’’, ‘’, $text); return $text; } function tel($page) { preg_match_all(’/
tel:</div>
.*?</div>/s’, $page, $m); if($m == ‘’){ $m =“brak tel”; } foreach($m AS $key => $value) { $tel = $value; } $GLOBALS[“tel”] = $tel; } function adres($page) { preg_match_all(’/
.*?</div>/s’, $page, $m); foreach($m AS $key => $value) { $adres = $value; } $GLOBALS[“adres”] = $adres; } function kartuzy(){ global $tel, $adres; $page = implode (’’, file (‘http://kartuzy.info/index.php?m=1&prc=0’)); preg_match_all(’/
.*?</h1>/s’, $page, $m); foreach($m AS $key => $value) { $nazwa = $value; } tel($page); adres($page); $x = count($nazwa); $i = 0; while($i < $x){ $a = filtr($tel[$i]); $b = filtr($adres[$i]); $c = filtr($nazwa[$i]); $return = "$return $c $a $b "; $i++; } return $return; } echo "
"; /*$file = “baza.txt”; for ($i = 0; $i < 1; $i++){ $dane = kartuzy($i); $fp = fopen($file, “a”); flock($fp, 2); fwrite($fp, $dane); flock($fp, 3); } fclose ($fp); */ ?>
jak stworzyć warunek jeżeli niema numeru tel, żeby pokazał się tekst “Brak tel”