note 74389 added to function.preg-replace

From: Date: Mon, 09 Apr 2007 17:45:27 +0000
Subject: note 74389 added to function.preg-replace
Groups: php.notes 
Request: Send a blank email to php-notes+get-125238@lists.php.net to get a copy of this message
Use this function to convert relative links in a block of HTML to absolute links which point to the specified absolute root: <?php function relative2absolute($html, $absolute_root, $doCss=false) { //SEE: http://wintermute.com.au/bits/2005-09/php-relative-absolute-links/ $str = preg_replace('#(href|src)="([^:"]*)("|(?:(?:%20|\s|\+)[^"]*"))#', '$1="' . $absolute_root . '/$2$3', $html); if($doCss) $str = str_replace('@import url("/', '@import url("' . $absolute_root . '/', $str); return $str; } ?> ---- Server IP: 69.39.81.135 Probable Submitter: 128.143.60.168 ---- Manual Page -- http://www.php.net/manual/en/function.preg-replace.php Edit -- https://master.php.net/note/edit/74389 Del: integrated -- https://master.php.net/note/delete/74389/integrated Del: useless -- https://master.php.net/note/delete/74389/useless Del: bad code -- https://master.php.net/note/delete/74389/bad+code Del: spam -- https://master.php.net/note/delete/74389/spam Del: non-english -- https://master.php.net/note/delete/74389/non-english Del: in docs -- https://master.php.net/note/delete/74389/in+docs Del: other reasons-- https://master.php.net/note/delete/74389 Reject -- https://master.php.net/note/reject/74389 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#125238) next »