<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>unexpected[it] &#187; PHP</title>
	<atom:link href="http://www.unexpectedit.com/category/php/feed" rel="self" type="application/rss+xml" />
	<link>http://www.unexpectedit.com</link>
	<description>Professional IT Blog</description>
	<lastBuildDate>Tue, 31 Jan 2012 21:55:19 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>PHP Clean String of UTF8 Chars &#8211; Convert to similar ASCII char</title>
		<link>http://www.unexpectedit.com/php/php-clean-string-of-utf8-chars-convert-to-similar-ascii-char</link>
		<comments>http://www.unexpectedit.com/php/php-clean-string-of-utf8-chars-convert-to-similar-ascii-char#comments</comments>
		<pubDate>Sat, 28 May 2011 14:29:44 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[ascii]]></category>
		<category><![CDATA[clean string]]></category>
		<category><![CDATA[cp1252]]></category>
		<category><![CDATA[utf8]]></category>
		<category><![CDATA[utf8 to ascii]]></category>
		<category><![CDATA[utf8 to similar ascii char]]></category>
		<category><![CDATA[windows 1252]]></category>

		<guid isPermaLink="false">http://www.unexpectedit.com/?p=610</guid>
		<description><![CDATA[Usage:]]></description>
			<content:encoded><![CDATA[<pre class="brush: php; title: ; notranslate">
	/**
	* Returns an string clean of UTF8 characters. It will convert them to a similar ASCII character
	* www.unexpectedit.com
	*/
function cleanString($text) {
	// 1) convert á ô =&gt; a o
	$text = preg_replace(&quot;/[áàâãªä]/u&quot;,&quot;a&quot;,$text);
	$text = preg_replace(&quot;/[ÁÀÂÃÄ]/u&quot;,&quot;A&quot;,$text);
	$text = preg_replace(&quot;/[ÍÌÎÏ]/u&quot;,&quot;I&quot;,$text);
	$text = preg_replace(&quot;/[íìîï]/u&quot;,&quot;i&quot;,$text);
	$text = preg_replace(&quot;/[éèêë]/u&quot;,&quot;e&quot;,$text);
	$text = preg_replace(&quot;/[ÉÈÊË]/u&quot;,&quot;E&quot;,$text);
	$text = preg_replace(&quot;/[óòôõºö]/u&quot;,&quot;o&quot;,$text);
	$text = preg_replace(&quot;/[ÓÒÔÕÖ]/u&quot;,&quot;O&quot;,$text);
	$text = preg_replace(&quot;/[úùûü]/u&quot;,&quot;u&quot;,$text);
	$text = preg_replace(&quot;/[ÚÙÛÜ]/u&quot;,&quot;U&quot;,$text);
	$text = preg_replace(&quot;/[’‘‹›‚]/u&quot;,&quot;'&quot;,$text);
	$text = preg_replace(&quot;/[“”«»„]/u&quot;,'&quot;',$text);
	$text = str_replace(&quot;–&quot;,&quot;-&quot;,$text);
	$text = str_replace(&quot; &quot;,&quot; &quot;,$text);
	$text = str_replace(&quot;ç&quot;,&quot;c&quot;,$text);
	$text = str_replace(&quot;Ç&quot;,&quot;C&quot;,$text);
	$text = str_replace(&quot;ñ&quot;,&quot;n&quot;,$text);
	$text = str_replace(&quot;Ñ&quot;,&quot;N&quot;,$text);

	//2) Translation CP1252. &amp;ndash; =&gt; -
	$trans = get_html_translation_table(HTML_ENTITIES);
	$trans[chr(130)] = '&amp;sbquo;';    // Single Low-9 Quotation Mark
	$trans[chr(131)] = '&amp;fnof;';    // Latin Small Letter F With Hook
	$trans[chr(132)] = '&amp;bdquo;';    // Double Low-9 Quotation Mark
	$trans[chr(133)] = '&amp;hellip;';    // Horizontal Ellipsis
	$trans[chr(134)] = '&amp;dagger;';    // Dagger
	$trans[chr(135)] = '&amp;Dagger;';    // Double Dagger
	$trans[chr(136)] = '&amp;circ;';    // Modifier Letter Circumflex Accent
	$trans[chr(137)] = '&amp;permil;';    // Per Mille Sign
	$trans[chr(138)] = '&amp;Scaron;';    // Latin Capital Letter S With Caron
	$trans[chr(139)] = '&amp;lsaquo;';    // Single Left-Pointing Angle Quotation Mark
	$trans[chr(140)] = '&amp;OElig;';    // Latin Capital Ligature OE
	$trans[chr(145)] = '&amp;lsquo;';    // Left Single Quotation Mark
	$trans[chr(146)] = '&amp;rsquo;';    // Right Single Quotation Mark
	$trans[chr(147)] = '&amp;ldquo;';    // Left Double Quotation Mark
	$trans[chr(148)] = '&amp;rdquo;';    // Right Double Quotation Mark
	$trans[chr(149)] = '&amp;bull;';    // Bullet
	$trans[chr(150)] = '&amp;ndash;';    // En Dash
	$trans[chr(151)] = '&amp;mdash;';    // Em Dash
	$trans[chr(152)] = '&amp;tilde;';    // Small Tilde
	$trans[chr(153)] = '&amp;trade;';    // Trade Mark Sign
	$trans[chr(154)] = '&amp;scaron;';    // Latin Small Letter S With Caron
	$trans[chr(155)] = '&amp;rsaquo;';    // Single Right-Pointing Angle Quotation Mark
	$trans[chr(156)] = '&amp;oelig;';    // Latin Small Ligature OE
	$trans[chr(159)] = '&amp;Yuml;';    // Latin Capital Letter Y With Diaeresis
	$trans['euro'] = '&amp;euro;';    // euro currency symbol
	ksort($trans); 

	foreach ($trans as $k =&gt; $v) {
		$text = str_replace($v, $k, $text);
	}

	// 3) remove &lt;p&gt;, &lt;br/&gt; ...
	$text = strip_tags($text); 

	// 4) &amp;amp; =&gt; &amp; &amp;quot; =&gt; '
	$text = html_entity_decode($text);

	// 5) remove Windows-1252 symbols like &quot;TradeMark&quot;, &quot;Euro&quot;...
	$text = preg_replace('/[^(\x20-\x7F)]*/','', $text); 

	$targets=array('\r\n','\n','\r','\t');
	$results=array(&quot; &quot;,&quot; &quot;,&quot; &quot;,&quot;&quot;);
	$text = str_replace($targets,$results,$text);

	return ($text);
} 
</pre>
<p><strong>Usage:</strong></p>
<pre class="brush: php; title: ; notranslate">
	$val = &quot;Arômes ... óòôõº ... áéíóú ... Barça ... “Windows quotes” ... this is not a normal space ( ) ... this is not a normal dash (–) ... Esdrújula ... Wünderlist ... &amp;#160; ... &amp;amp; ... &amp; ... &amp;rsquo; ... &amp;ndash; ... &amp;pound; ... &amp;euro; ... &amp;nbsp; ... 	...&quot;;
	echo cleanString($val);
	//result: Aromes ... ooooo ... aeiou ... Barca ... &quot;Windows quotes&quot; ... this is not a normal space ( ) ... this is not a normal dash (-) ... Esdrujula ... Wunderlist ... ... &amp; ... &amp; ... ... ... ... euro ... ... ...

	//Note: If you get an empty string, make sure you pass utf8 string to the function
	echo cleanString(utf8_encode($val));
</pre>
<div id="wpcr_respond_1"></div>]]></content:encoded>
			<wfw:commentRss>http://www.unexpectedit.com/php/php-clean-string-of-utf8-chars-convert-to-similar-ascii-char/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>PHP Networking &#8211; Http Request</title>
		<link>http://www.unexpectedit.com/php/php-networking-http-request</link>
		<comments>http://www.unexpectedit.com/php/php-networking-http-request#comments</comments>
		<pubDate>Fri, 17 Sep 2010 14:18:00 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[Content-type]]></category>
		<category><![CDATA[header]]></category>

		<guid isPermaLink="false">http://www.unexpectedit.com/?p=326</guid>
		<description><![CDATA[]]></description>
			<content:encoded><![CDATA[<pre class="brush: php; title: ; notranslate">
//Header to create a file and send to the browser
header(&quot;Content-type: application/octet-stream&quot;);
header(&quot;Content-Disposition: attachment; filename=\&quot;filename.xml\&quot;&quot;);
$data='&lt;?xml version=&quot;1.0&quot; encoding=&quot;utf-8&quot;?&gt;' . &quot;\n&quot;;
$data.='&lt;data&gt;My Data&lt;/data&gt;' . &quot;\n&quot;;
echo $data;

//Header to send an existing file to the browser
$filename = '/var/www/html/rates.csv';
header('Content-type: application/csv');
header(&quot;Content-Disposition: inline; filename=&quot;.$filename);
readfile($filename);
</pre>
<div id="wpcr_respond_1"></div>]]></content:encoded>
			<wfw:commentRss>http://www.unexpectedit.com/php/php-networking-http-request/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>PHP Handling Non-English Characters UTF8</title>
		<link>http://www.unexpectedit.com/php/php-handling-non-english-characters-utf8</link>
		<comments>http://www.unexpectedit.com/php/php-handling-non-english-characters-utf8#comments</comments>
		<pubDate>Wed, 18 Aug 2010 12:49:25 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[same length]]></category>
		<category><![CDATA[utf8]]></category>
		<category><![CDATA[utf8_decode]]></category>
		<category><![CDATA[utf8_encode]]></category>

		<guid isPermaLink="false">http://www.unexpectedit.com/?p=300</guid>
		<description><![CDATA[]]></description>
			<content:encoded><![CDATA[<pre class="brush: php; title: ; notranslate">
	/**
	* Returns an string with the same length.
	* - If it is smaller than num it will fill out with the fill character.
	* - If it is larger than num it will cut the string.
	* www.unexpectedit.com
	*/
	function formatcell($data, $num, $fill=' '){
	    $data = trim($data);
		$data=str_replace(chr(13),' ',$data);
		$data=str_replace(chr(10),' ',$data);
		// translate UTF8 to English characters
		$data = iconv('UTF-8', 'ASCII//TRANSLIT', $data);
		$data = preg_replace(&quot;/[\'\&quot;\^\~\`]/i&quot;, '', $data);

		// fill it up with spaces
    	for ($i = strlen($data); $i &lt; $num; $i++) {
    		$data .= $fill;
    	}
    	// limit string to num characters
   		$data = substr($data, 0, $num);

		return $data;
    }

    echo formatcell(&quot;YES UTF8 String Zürich&quot;, 25, 'x'); //YES UTF8 String ZÃ¼richxxx
    echo formatcell(&quot;NON UTF8 String Zurich&quot;, 25, 'x'); //NON UTF8 String Zurichxxx
</pre>
<div id="wpcr_respond_1"></div>]]></content:encoded>
			<wfw:commentRss>http://www.unexpectedit.com/php/php-handling-non-english-characters-utf8/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>.htaccess PHP Error Reporting</title>
		<link>http://www.unexpectedit.com/php/htaccess-php-error-reporting</link>
		<comments>http://www.unexpectedit.com/php/htaccess-php-error-reporting#comments</comments>
		<pubDate>Wed, 04 Aug 2010 20:59:27 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[display_errors]]></category>
		<category><![CDATA[error_reporting]]></category>
		<category><![CDATA[E_ALL]]></category>

		<guid isPermaLink="false">http://www.unexpectedit.com/?p=238</guid>
		<description><![CDATA[]]></description>
			<content:encoded><![CDATA[<pre class="brush: bash; title: ; notranslate">
php_flag display_errors off
php_value error_reporting 7
</pre>
<div id="wpcr_respond_1"></div>]]></content:encoded>
			<wfw:commentRss>http://www.unexpectedit.com/php/htaccess-php-error-reporting/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>PHP mysqldump Script &#8211; Backup a MySQL Database</title>
		<link>http://www.unexpectedit.com/php/php-mysqldump-script-backup-a-mysql-database</link>
		<comments>http://www.unexpectedit.com/php/php-mysqldump-script-backup-a-mysql-database#comments</comments>
		<pubDate>Thu, 22 Jul 2010 13:48:16 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[backup]]></category>
		<category><![CDATA[database]]></category>
		<category><![CDATA[export]]></category>
		<category><![CDATA[mysql]]></category>
		<category><![CDATA[mysqldump]]></category>
		<category><![CDATA[script]]></category>

		<guid isPermaLink="false">http://www.unexpectedit.com/?p=183</guid>
		<description><![CDATA[]]></description>
			<content:encoded><![CDATA[<pre class="brush: php; title: ; notranslate">
/**
* PHP mysqldump Script
* www.unexpectedit.com
*/
$dbname=&quot;magentoDatabase&quot;;
$dbhost=&quot;localhost&quot;;
$dbuser=&quot;root&quot;;
$dbpass=&quot;123456&quot;;

$backupFile = $dbname . date(&quot;Y-m-d-H-i-s&quot;)  . '.gz';
$command = &quot;mysqldump --opt -h $dbhost -u'$dbuser' -p'$dbpass' $dbname | gzip &gt; $backupFile&quot;;
$returned = system($command);
echo $returned;
</pre>
<div id="wpcr_respond_1"></div>]]></content:encoded>
			<wfw:commentRss>http://www.unexpectedit.com/php/php-mysqldump-script-backup-a-mysql-database/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>PHP Email Functions</title>
		<link>http://www.unexpectedit.com/php/php-email-functions</link>
		<comments>http://www.unexpectedit.com/php/php-email-functions#comments</comments>
		<pubDate>Mon, 14 Jun 2010 19:20:45 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[attach]]></category>
		<category><![CDATA[email]]></category>
		<category><![CDATA[files]]></category>
		<category><![CDATA[function]]></category>

		<guid isPermaLink="false">http://www.unexpectedit.com/?p=104</guid>
		<description><![CDATA[]]></description>
			<content:encoded><![CDATA[<pre class="brush: php; title: ; notranslate">
/**
* PHP Email Functions
* www.unexpectedit.com
*/
function sendEmail($to, $from, $subject, $message, $files) {
	$headers = &quot;From: $from&quot;;
	// boundary
	$semi_rand = md5(time());
	$mime_boundary = &quot;==Multipart_Boundary_x{$semi_rand}x&quot;;
	// headers for attachment
	$headers .= &quot;\nMIME-Version: 1.0\n&quot; . &quot;Content-Type: multipart/mixed;\n&quot; . &quot; boundary=\&quot;{$mime_boundary}\&quot;&quot;;
	// multipart boundary
	$message = &quot;This is a multi-part message in MIME format.\n\n&quot; . &quot;--{$mime_boundary}\n&quot; . &quot;Content-Type: text/plain; charset=\&quot;iso-8859-1\&quot;\n&quot; . &quot;Content-Transfer-Encoding: 7bit\n\n&quot; . $message . &quot;\n\n&quot;;
	$message .= &quot;--{$mime_boundary}\n&quot;;
	// preparing attachments
	for($x=0;$x&lt;count($files);$x++){
		$file = fopen($files[$x],&quot;rb&quot;);
		$data = fread($file,filesize($files[$x]));
		fclose($file);
		$data = chunk_split(base64_encode($data));
		$message .= &quot;Content-Type: {\&quot;application/octet-stream\&quot;};\n&quot; . &quot; name=\&quot;$files[$x]\&quot;\n&quot; .
	&quot;Content-Disposition: attachment;\n&quot; . &quot; filename=\&quot;$files[$x]\&quot;\n&quot; .
	&quot;Content-Transfer-Encoding: base64\n\n&quot; . $data . &quot;\n\n&quot;;
		$message .= &quot;--{$mime_boundary}\n&quot;;
	}
	// send
	$ok = @mail($to, $subject, $message, $headers);
	return $ok;
}

//Usage:
// array with filenames to be sent as attachment
$files = array(&quot;file_1.ext&quot;,&quot;/tmp/file_2.ext&quot;,&quot;/home/guest/file_3.ext&quot;);
// email fields: to, from, subject, and so on
$to = &quot;root@localhost&quot;;
$from = &quot;mail@mail.com&quot;;
$subject =&quot;My subject&quot;;
$message = &quot;My message&quot;;

sendEmail($to, $from, $subject, $message, $files);
</pre>
<div id="wpcr_respond_1"></div>]]></content:encoded>
			<wfw:commentRss>http://www.unexpectedit.com/php/php-email-functions/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>PHP Browser Functions</title>
		<link>http://www.unexpectedit.com/php/php-browser-functions</link>
		<comments>http://www.unexpectedit.com/php/php-browser-functions#comments</comments>
		<pubDate>Mon, 14 Jun 2010 19:03:45 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[browser detection]]></category>
		<category><![CDATA[HTTP_USER_AGENT]]></category>
		<category><![CDATA[S_SEVER["HTTP_USER_AGENT"]]]></category>

		<guid isPermaLink="false">http://www.unexpectedit.com/?p=100</guid>
		<description><![CDATA[]]></description>
			<content:encoded><![CDATA[<pre class="brush: php; title: ; notranslate">
/**
* Browser Detection Functions
* www.unexpectedit.com
*/
function inAgent($agent) {
	global $_SERVER;
	return (strpos($_SERVER['HTTP_USER_AGENT'], $agent) === false) ? false : true;
}

function whichBrowser() {
	/*
	* $browser will contain one of the following values:
	* 'iewin' : IE 4+ for Windows
	* 'iemac' : IE 4 for Macintosh
	* 'ie5mac' : IE 5 Macintosh
	* 'nswin' : Netscape 4.x Windows
	* 'nsunix' : Netscape 4.x Unix
	* 'nsmac' : Netscape 4.x Mac
	* 'ns6' : Netscape 6 / Mozilla
	*/
	switch (inAgent('MSIE'))
	{
		case true:
			if ( inAgent('Mac') ) {
				$browser = inAgent('MSIE 5') ? 'ie5mac' : 'ie4mac';
			}
			elseif ( inAgent('Win') )
			{
				$browser = 'iewin';
			}
			break;

		case false:
			if (inAgent('Mozilla/5')) {
				$browser = 'ns6';
			}
			elseif (inAgent('Mozilla/4'))
			{
				if ( inAgent('Mac'))
				{
					$browser = 'nsmac';
				}
				else
				{
				$browser = (inAgent('Win')) ? 'nswin' : 'nsunix';
				}
			}
			else
			{
				$browser = &quot;unknown&quot;;
			}
			break;
	}
	return($browser);
}

// browser detection - end
switch (whichBrowser())
{
	case 'iewin': case 'iemac': case 'ie5mac':
		echo &quot;independent&quot;;
		break;
	case 'nswin': case 'nsunix': case 'nsmac': case 'ns6':
		echo &quot;microsoft&quot;;
		break;
}
</pre>
<div id="wpcr_respond_1"></div>]]></content:encoded>
			<wfw:commentRss>http://www.unexpectedit.com/php/php-browser-functions/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>PHP Security Functions</title>
		<link>http://www.unexpectedit.com/php/php-security-functions</link>
		<comments>http://www.unexpectedit.com/php/php-security-functions#comments</comments>
		<pubDate>Fri, 11 Jun 2010 13:39:58 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[generate]]></category>
		<category><![CDATA[mt_rand]]></category>
		<category><![CDATA[random]]></category>
		<category><![CDATA[security]]></category>
		<category><![CDATA[uid]]></category>

		<guid isPermaLink="false">http://www.unexpectedit.com/?p=98</guid>
		<description><![CDATA[]]></description>
			<content:encoded><![CDATA[<pre class="brush: php; title: ; notranslate">
/**
* Security Functions
* www.unexpectedit.com
*/
//UID generate unique random number/letters or a random password
function generateUID($length=32) {
	$pass=&quot;&quot;;
	for($k=0; $k &lt; $length; $k++) {
		$prob = mt_rand(1,10);
		if($prob &lt;= 3) // A-Z probability: 30%
			$pass .=  chr(mt_rand(65,90));
		if($prob &lt;= 6 )   //a-z probability is 30%
			$pass .= chr(mt_rand(97,122));
		else //0-9 probability is 40%
			$pass .= chr(mt_rand(48, 57));
	}
	return $pass;
}
</pre>
<div id="wpcr_respond_1"></div>]]></content:encoded>
			<wfw:commentRss>http://www.unexpectedit.com/php/php-security-functions/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>PHP Send Mail Function</title>
		<link>http://www.unexpectedit.com/php/php-send-mail-function</link>
		<comments>http://www.unexpectedit.com/php/php-send-mail-function#comments</comments>
		<pubDate>Thu, 10 Jun 2010 21:57:59 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[attachment]]></category>
		<category><![CDATA[email]]></category>

		<guid isPermaLink="false">http://www.unexpectedit.com/?p=92</guid>
		<description><![CDATA[]]></description>
			<content:encoded><![CDATA[<pre class="brush: php; title: ; notranslate">
/**
* Send an email with file attached
* www.unexpectedit.com
*/
public function send($fileatt, $from, $to) {
 $headers = &quot;From: &quot;.&quot;ordermanagement@handpickedcollection.com&quot;;
 $semi_rand = md5(time());
 $mime_boundary = &quot;==Multipart_Boundary_x{$semi_rand}x&quot;;
  $headers .= &quot;\nMIME-Version: 1.0\n&quot; .
    &quot;Content-Type: multipart/mixed;\n&quot; .
    &quot; boundary=\&quot;{$mime_boundary}\&quot;&quot;;
  $email_message = &quot;This is a multi-part message in MIME format.\n\n&quot; .
   &quot;--{$mime_boundary}\n&quot; .
   &quot;Content-Type:text/plain; charset=\&quot;iso-8859-1\&quot;\n&quot; .
   &quot;Content-Transfer-Encoding: 7bit\n\n&quot;;
   /* PREPARE ATTACHMENT */
   $fileatt_type = &quot;application/octet-stream&quot;;
   $file = fopen($fileatt,'rb');
   $data = fread($file,filesize($fileatt));
   fclose($file);
   $data = chunk_split(base64_encode($data));
   $email_message .= &quot;--{$mime_boundary}\n&quot; .
   &quot;Content-Type: application/octet-stream;\n&quot; .
   &quot; name=\&quot;{$fileatt}\&quot;\n&quot; .
   &quot;Content-Transfer-Encoding: base64\n\n&quot; .
   $data . &quot;\n\n&quot; .
   &quot;--{$mime_boundary}--\n&quot;;
   $strto=gmdate(&quot;dS M,Y H:i&quot;, strtotime($to));
   $ok = mail(&quot;ignacio@richardmason.net&quot;, &quot;Unprocessed orders:      $strto&quot;, $email_message, $headers);
   return($ok);
 }
</pre>
<div id="wpcr_respond_1"></div>]]></content:encoded>
			<wfw:commentRss>http://www.unexpectedit.com/php/php-send-mail-function/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>PHP Text Manipulation Functions</title>
		<link>http://www.unexpectedit.com/php/php-useful-functions</link>
		<comments>http://www.unexpectedit.com/php/php-useful-functions#comments</comments>
		<pubDate>Thu, 10 Jun 2010 21:41:25 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[functions]]></category>
		<category><![CDATA[manipulation]]></category>
		<category><![CDATA[string]]></category>
		<category><![CDATA[text]]></category>
		<category><![CDATA[uid]]></category>

		<guid isPermaLink="false">http://www.unexpectedit.com/?p=88</guid>
		<description><![CDATA[]]></description>
			<content:encoded><![CDATA[<pre class="brush: php; title: ; notranslate">
/**
* Text Manipulation Functions
* www.unexpectedit.com
*/
function html_cut_text($text,$limit) {
	$max_code=8; // max for special code like &amp;permil; &amp;aacute; ...
	if(($limit&lt;&gt;0)&amp;&amp;(strlen($text)&gt;$limit)) {
		$pos=strpos(substr($text,0,$limit+$max_code),';'); //find ;
	if($pos) // cut when pass ;
		$text=substr($text,0,$pos+1);
	else //cut at limit
		$text=substr($text,0,$limit);
	return($text.&quot;...&quot;);
	}
	else
		return($text); // return
}
</pre>
<div id="wpcr_respond_1"></div>]]></content:encoded>
			<wfw:commentRss>http://www.unexpectedit.com/php/php-useful-functions/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

