Beispiel #1
0
function range_end_line($file, $line)
{
    $s = file_get_contents($file);
    $rn = strpos($s, "\r\n") === FALSE ? "\n" : "\r\n";
    $len = strlen($rn);
    if ($line == 0) {
        return 0;
    }
    $pos = strnpos($s, $rn, $line);
    // 如果等于 FALSE 则为文件末尾
    $pos === FALSE and $pos = strlen($s);
    return $pos;
}
Beispiel #2
0
function check_rmtp_url($url)
{
    $slashes_number = substr_count($url, '/');
    $string = $url;
    $nthtimes = 4;
    $replaceme = '/';
    if ($slashes_number == 5) {
        //echo "stringa modificata<br>";
        $pos_4 = strnpos($url, $replaceme, $nthtimes);
        //echo "posizione  $nthtimes slashes : $pos_4<br>";
        $new_url = substr($url, 0, $pos_4) . '/' . substr($url, -(strlen($url) - $pos_4));
        return $new_url;
    }
    return $url;
}
Beispiel #3
0
function get_hotel_description_from_bad_xml($badXml)
{
    $descriptionStart = strpos($badXml, "<Line/>") + 18;
    $descriptionEnd = strpos($badXml, "<Line/>", $descriptionStart);
    $hotelDescription = substr($badXml, $descriptionStart, $descriptionEnd - $descriptionStart);
    if (substr_count($hotelDescription, "<Line>") > 9) {
        $lastLine = strnpos($hotelDescription, "<Line>", 10);
        $hotelDescription = substr($hotelDescription, 0, $lastLine);
        $hotelDescription .= "...";
    }
    $hotelDescription = str_replace("<Line>", "", $hotelDescription);
    $hotelDescription = str_replace("</Line>", "", $hotelDescription);
    return $hotelDescription;
}