[php] косяккк

Discussion in 'PHP' started by rubik-nerubik, 1 Jul 2009.

  1. rubik-nerubik

    rubik-nerubik Elder - Старейшина

    Joined:
    4 May 2007
    Messages:
    248
    Likes Received:
    9
    Reputations:
    -2
    Нужно следующее: открыть страницу
    http://gismeteo.ru/city/catalog/cities/?country=RU&id=156

    принять тупо от А до Я т.е. от <li class="redLetter">А</li> до >Ярославская обл.</a></li>

    и вывести на экран пробовал сам :
    PHP:
    $file file_get_contents('http://gismeteo.ru/city/catalog/cities/?country=RU&id=156'); 


    $start1 '<li class="redLetter">А</li>';
    $end1'<div class="M123">';
    preg_match_all('|' strtok($start1,'%|%') . '(.*)' strtok($end1,'%|%') . '|sU',$file,$found1); 
    if(
    $found1[1][0]) 
    {      
    $cit=$found1[1][0];  
    } else { 
    $cit='Ошибка!'; } 

    .....
    include(
    'ind.html');
    внизу инклуд инда е просто так указан, вот когда всё обрабатывается, то по идее он должен все вывести грубо говоря от А до Я и инклуд ind,так? но он выводит от А до Ч %) и не выводит ind...... спросил в тех поддержки хостинга малоли мож обрезает типа на строное сервера, но там нет ограничения... странно, мега странно, может кто свой кусок кода даст? типа открывает копирует часть и выводит.
     
  2. Pashkela

    Pashkela Динозавр

    Joined:
    10 Jan 2008
    Messages:
    2,750
    Likes Received:
    1,044
    Reputations:
    339
    Code:
    <pre>
    <?php
    $file = file_get_contents('http://gismeteo.ru/city/catalog/cities/?country=RU&id=156');  
    preg_match_all('|<li><a href=.*>(.*)</a></li>|Ui',$file,$found1);  
    print_r($found1[1]);
    ?>
    </pre>
    
     
  3. rubik-nerubik

    rubik-nerubik Elder - Старейшина

    Joined:
    4 May 2007
    Messages:
    248
    Likes Received:
    9
    Reputations:
    -2
    ссылки тоже надо сохранить
     
  4. rubik-nerubik

    rubik-nerubik Elder - Старейшина

    Joined:
    4 May 2007
    Messages:
    248
    Likes Received:
    9
    Reputations:
    -2
    добавил так:
    PHP:
    $file file_get_contents('http://gismeteo.ru/city/catalog/cities/?country=RU&id=156');  
    preg_match_all('|<li><a href=.*>(.*)</a></li>|Ui',$file,$found1);  
    if(
    $found1[0][1]) { print_r($found1[0][1]);} else { print_r('Ошибка.'); } 
    выводит толко первую ссылку, а надо все)