Ben, böyle bir şey bir web doc içinde URL'ler bir dizi var:
<a href="somepage.php?x=some_document.htm">click here</a>
Ne yapmak istiyorum kalın parça değiştirin:
.. Şifreli varyasyon (sadece base64_encoding diyelim) .. gibi bir şey bu çeşit ile:
for each match, turn it into base64_encode(match)
Notes:
1.the ifade href="somepage.php?x= her zaman ifade önce gelecek.
2.a double-quote (") her zaman ifade takip edecek.
Ben bir regex guru değilim - ama senden bazı biliyorum. Bunu yapmanın kolay bir yolu?
UPDATE:
Ben Chris sunulan ne değiştirilmiş bir sürümünü kullanarak bu çözülebilir, işte burada:
function encrypt_param( $in_matches ) {
return 'href="somepage.php?x=' . base64_encode( $in_matches[1] ) . '"';
}
$webdoc = preg_replace_callback( '/href="somepage.php\?x=([^"]+)"/',
'encrypt_param',
$webdoc );