'domain.net/script.php?variab=value'
These are inside custom tags (<my_title>, <new_edit>).
I also have an script thats supposed to add some new entries into that
abovementioned html file AND also remove some of the older parts.
I've split the functionality into two parts.
Script A loads the html, formats the data to be added and calls script B,
formats the result and saves the html.
Script B is simply a 'remove tag' -function. It takes as arguments a
string, start string and end string.
It returns false if nothing was found&removed.
If start and end were found it returns an array:
temp[0]=trimmed_original_string, temp[1]=string_between_start_and_end
Everything worked fine when I developed this for plain html links. IOW,
no urls with '=' or '?'.
Now I need to call php script and pass variables and suddenly the
script B gets caught in infinite loop (stopped after 30 seconds).
Please help me out. I am really getting nowhere
Here is the script B.
To use it one needs to test if the result === "false" -> nothing replaced.
Else [0] and [1] are returned as mentioned above.
Code: Select all
<?php
/* Funktio Poista (Function Remove)
Searches and replaces the first string between $stralku and $strloppu (including arg strings).
Etsii ja poistaa ensinmäisen alku- ja loppustringin välissä olevan osan kokostringistä,
Palauttaa tulokset jonossa jossa ї0] putsatun kokostringin ja ї1] poistettu osa.
*/
function poista($kokostring, $stralku, $strloppu) { //args: string string, string start, string end
//etsitään alku
$ekstrak_alku = strpos($kokostring, $stralku);
if ($ekstrak_alku === false) { //oletettavasti alku ei löytynyt
$poistofunktiojonoї0] = ""; $poistofunktiojonoї1] = "";
return "false"; //ei löytynyt alkustringiä
}
//loppustringin pituus
$loppustr_pit = strlen($strloppu);
//kohta josta loppustring alkaa
$ekstrak_loppustringinalku = strpos($kokostring, $strloppu, $ekstrak_alku);
if ($ekstrak_loppustringinalku === false) {
$poistofunktiojonoї0] = ""; $poistofunktiojonoї1] = "";
return "false"; //ekstrak loppua ei löydy
}
//oletettavasti loppustring löytyi
//koko stringin pituus
$ekstrak_pituus = $ekstrak_loppustringinalku + $loppustr_pit - $ekstrak_alku;
//poistettava string on
$ekstrak_sisus = substr($kokostring, $ekstrak_alku, $ekstrak_pituus);
//poistetaan string
$poistofunktiojonoї0] = substr_replace ($kokostring, " ", $ekstrak_alku, $ekstrak_pituus); //REMOVES '=' and '?'
//eregi_replace($ekstrak_sisus, ' ', $kokostring); //INFINITE LOOP
$poistofunktiojonoї1] = $ekstrak_sisus;
return $poistofunktiojono;
} //e_poista
?>jani