note 18924 deleted from function.preg-replace by sniper
| From: | sniper@php.net | Date: | Tue, 30 Sep 2003 12:29:40 +0000 |
| Subject: | note 18924 deleted from function.preg-replace by sniper | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-57469@lists.php.net to get a copy of this message | ||
Note Submitter: skd2@ece.msstate.edu
----
To whoever is working on on-the-fly conversion
from HTML to WML - while converting, we remove all
the tags, but in order to navigate we have to
preserve the links on the html page onto
the corresponding WML page for which I suggest the
following - took a while to figure it out...
After the HTML content is read into $document variable:
$document =
preg_replace("'<a
href=[\"|\'](.*[^>])[\"|\']>(.*[^<>])</a>'i",
"<a href=\"converter.php?
file=\\1\"> \\2 </a><br/>",$document);
$search = array("'&(lt|#60);'i", "'&(gt|#62);'i");
$replace = array("<",">");
$document = preg_replace($search, $replace, $document);
The program file that would do the on-the-fly convertion
is named as 'converter.php'.The code will rewrite and copy
the links onto the WML page. The links have to be rewritten
to be parsed by the code because they still point to
HTML pages. So, whenever a link (that points to the
html page) is clicked, on the WML page, the page is
retrieved and converted into WML format and ofcourse
the links are rewritten again, as a recursive process.
If the link on HTML page was :
<a href="/test/index.html">Test</a>
On the WML page, it would show up as :
<a href="converter.php?file=/test/index.html">Test</a>