|
|
|
<?
/* Produces browser-safe strings while preserving HTML tags.
* This function takes the string "ISTRING" as an argument and returns
* the string "OSTRING". All special characters from "ISTRING" are
* converted to browser-safe HTML codes using htmlentities(), and HTML
* tags are left intact and functional.
*/
// Contributed Nov 2000 by Jason Galvin: <www.jasongalvin.com>
function guardHTML($istring) {
$stringarr = preg_split('//', $istring);
$stringlen = count($stringarr);
for($i=0; $i<$stringlen; ++$i){
if($stringarr[$i] == "<"){
while($i<$stringlen){
$HTMLtag .= $stringarr[$i];
++$i;
if($stringarr[($i-1)] == ">") break;
}
--$i;
} else {
while($stringarr[$i] != "<" && $i<$stringlen){
$nonHTML .= $stringarr[$i];
++$i;
}
--$i;
}
$ostring .= $HTMLtag;
$HTMLtag = "";
$ostring .= htmlentities($nonHTML);
$nonHTML = "";
}
return $ostring;
}
?> |
|
| Parse string to find sub-string between two arbitrary strings Categories : PHP, Strings, HTML and PHP, Arrays | | | Customizable encoding and decoding strings with security. Categories : PHP, Strings, HTML and PHP | | | Browser Detection, Redirection Type, MSIE, MOZILLA, Netscape Navigator, NS, $HTTP_USER_AGENT, HTTP_USER_AGENT Categories : PHP, HTTP, Browsers, HTML and PHP | | | Pseudo Non Parsed Header. Output to the the browser as the script runs. Categories : PHP, HTTP, HTML and PHP | | | PHP4 HTTP Compression Speeds up the Web Categories : PHP, Zlib, HTML and PHP, HTTP, Network | | | Pull deliniated text strings into a "SELECT" statement in a form. Categories : HTML and PHP, PHP, Strings | | | function textwrap will wrap text to any desired width using <BR>\n as the default line break.
Default wrap width is 80 columns.
Categories : Strings, HTML and PHP, PHP | | | string justification align center text Categories : Strings, PHP, HTML and PHP | | | How to let a user download a picture by clicking on it instead of needing to right click and Save-As. Categories : HTTP, PHP, HTML and PHP, Filesystem | | | Text Wrapping Categories : PHP, HTML and PHP, Strings | | | PHP3: Formmail. Just a cgi formmail, but than in PHP. It is easy to use! Categories : HTML and PHP, Email, PHP, Perl, HTML and PHP | | | Upload Script, Upload File Script, Input Type="File" Categories : PHP, HTML and PHP, HTTP | | | This script shows you the 7th latest php items from the mailing list archive on zend.com Categories : HTML, HTML and PHP, HTTP, PHP | | | Database resultset navigation Categories : PHP, HTML and PHP, Databases, MySQL, Navigation | | | webcam cam view image ispy browser independant Categories : Graphics, HTML, HTML and PHP, PHP | |
|
|