PHP Salt


A little dash of PHP... my collection of php functions

Version: 2.33.2
Last Build: December 29, 2023 20:28pm (PST)

Main Menu

Home

Get PHP Salt


The Functions

array
db
file
graph
html
mail
math
misc
mobile
script
string
system
time
web
psShrinkSource()
Shrinks an HTML source string


Description:

I wanted to remove a lot of unwanted chrs, spaces, tabs, newlines,
etc from a web page source. so I came up with this function.



Usage:

$buffer = psShrinkSource($buffer);



Example:

	$buffer = psShrinkSource("<HTML> <BODY> <BR> <BR> </BODY> </HTML>");
// returns "<HTML><BODY><BR><BR></BODY></HTML>"




Code:

function psShrinkSource($buffer)
{
$buffer = preg_replace('/\s\s+/', ' ', $buffer); // excess white space
$buffer = preg_replace('/^[ \t\r\n]+/m', '', $buffer);
$buffer = str_replace("> <meta","><meta",$buffer);
$buffer = str_replace(" <BR>","<BR>",$buffer);
$buffer = str_replace("<BR> ","<BR>",$buffer);
$buffer = str_replace(" <DIV","<DIV",$buffer);

return $buffer;
}


Changlelog:



See Also

And a shot out to:

PHP - php.net
Fedora Server - getfedora.com
Shameless ads to pay for site