static public function encode($str, $for_qbxml = true, $double_encode = true)
	{
		$transform = array(
			'&' => '&amp;', 
			'<' => '&lt;', 
			'>' => '&gt;', 
			//'\'' => '&apos;', 
			'"' => '&quot;', 
			);
		
		$str = str_replace(array_keys($transform), array_values($transform), $str);
		
		if (!$double_encode)
		{
			$fix = array();
			foreach ($transform as $raw => $encoded)
			{
				$fix[str_replace('&', '&amp;', $encoded)] = $encoded;
			}
			
			$str = str_replace(array_keys($fix), array_values($fix), $str);
		}
		
		return $str;
	}
static public function encode($str, $for_qbxml = true, $double_encode = true)
	{
		$transform = array(
			'&' => '&amp;', 
			'<' => '&lt;', 
			'>' => '&gt;', 
			//'\'' => '&apos;', 
			'"' => '&quot;', 
			);
		
		$str = str_replace(array_keys($transform), array_values($transform), $str);
		
		if (!$double_encode)
		{
			$fix = array();
			foreach ($transform as $raw => $encoded)
			{
				$fix[str_replace('&', '&amp;', $encoded)] = $encoded;
			}
			
			$str = str_replace(array_keys($fix), array_values($fix), $str);
		}
		
		return $str;
	}
static public function encode ( $ str , $ for_qbxml = true , $ double_encode = true ) { $ transform = array ( '&' => '&amp;' , '<' => '&lt;' , '>' => '&gt;' , //'\'' => '&apos;',  '"' => '&quot;' , ) ; $ str = str_replace ( array_keys ( $ transform ) , array_values ( $ transform ) , $ str ) ; if ( ! $ double_encode ) { $ fix = array ( ) ; foreach ( $ transform as $ raw => $ encoded ) { $ fix [ str_replace ( '&' , '&amp;' , $ encoded ) ] = $ encoded ; } $ str = str_replace ( array_keys ( $ fix ) , array_values ( $ fix ) , $ str ) ; } return $ str ; }
Encode a string for use within an XML document

@todo Investigate QuickBooks qbXML encoding and implement solution

@param string $str				The string to encode
@param boolean $for_qbxml
@return string
Encode a string for use within an XML document