G
G
grechnik2282015-09-24 15:38:33
PHP
grechnik228, 2015-09-24 15:38:33

Php to substitute in turn?

<?php

$search_engines = array(
    'blogsearch.com' => 'http://blogsearch.google.com/ping?url=',
);

$search_engine_responses = array(
    'blogsearch.com' => 'Thanks',
);

$sitemaps = array(
    'Site 1' => 'http://gggg.com/url3',
    'Site 2' => 'http://gggg.com/url3',
    'Site 3' => 'http://gggg.com/url3'
);

foreach($search_engines as $engine_name => $engine_url){
    echo "<p><b>$engine_name</b>";
    foreach($sitemaps as $site_name => $site_map){
        $response = file_get_contents($engine_url.$site_map);
        echo "<br>";
        if(substr_count($response, $search_engine_responses[$engine_name])){
            echo $site_name.": <span style='color: green;'>Success</span>";
        }
        else{
            echo $site_name.": <span style='color: red;'>Failure</span>";
        }
    }
    echo "</p>";
}

?>

There is a list of $sitemaps in txt file
. How to make them taken from the file one by one?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
L
Lander, 2015-09-24
@usdglander

file() + foreach in
more detail:

$list = file('sites.txt');
foreach ($list as $item) {
    //$item - одна строка из файла.
    //делаем что нужно
}

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question