<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DZone Snippets: php code</title>
    <link>http://snippets.dzone.com/posts</link>
    <pubDate>Fri, 25 Jul 2008 05:50:21 GMT</pubDate>
    <description>DZone Snippets: php code</description>
    <item>
      <title>function array2object() in PHP 5</title>
      <link>http://snippets.dzone.com/posts/show/5794</link>
      <description>function array2object() in PHP 5&lt;br /&gt;&lt;br /&gt;&lt;code&gt;&lt;br /&gt;function array2object(array $array) {&lt;br /&gt;	$object = new stdClass();&lt;br /&gt;	foreach($array as $key =&gt; $value) {&lt;br /&gt;		if(is_array($value)) {&lt;br /&gt;			$object-&gt;$key = array2object($value);&lt;br /&gt;		} else {&lt;br /&gt;			$object-&gt;$key = $value;&lt;br /&gt;		}&lt;br /&gt;	}&lt;br /&gt;	return $object;&lt;br /&gt;}&lt;br /&gt;&lt;/code&gt;&lt;br /&gt;&lt;br /&gt;&lt;a href="http://www.ab-d.fr/"&gt;Source: &lt;/a&gt;&lt;a href="http://www.ab-d.fr/date/2008-07-19/"&gt;function array2object(array $array) in PHP5 ( object, stdClass )&lt;/a&gt;</description>
      <pubDate>Sat, 19 Jul 2008 08:24:18 GMT</pubDate>
      <guid>http://snippets.dzone.com/posts/show/5794</guid>
      <author>ki4ngel (Benoit Asselin)</author>
    </item>
    <item>
      <title>Return several values from a function PHP</title>
      <link>http://snippets.dzone.com/posts/show/5724</link>
      <description>Return several values from a function PHP&lt;br /&gt;&lt;br /&gt;&lt;code&gt;&lt;br /&gt;&lt;?php&lt;br /&gt;&lt;br /&gt;function return_several_values() {&lt;br /&gt;	$variable_n_1 = 'One';&lt;br /&gt;	$variable_n_2 = 'Two';&lt;br /&gt;	$variable_n_3 = '333';&lt;br /&gt;	&lt;br /&gt;	return array($variable_n_1, $variable_n_2, $variable_n_3);&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;list($variable_n_1, $variable_n_2, $variable_n_3) = return_several_values();&lt;br /&gt;&lt;br /&gt;?&gt;&lt;br /&gt;&lt;/code&gt;&lt;br /&gt;&lt;br /&gt;&lt;a href="http://www.ab-d.fr/date/2008-07-05/"&gt;Source code: retourner plusieurs valeurs depuis une fonction PHP&lt;/a&gt;</description>
      <pubDate>Sat, 05 Jul 2008 17:20:39 GMT</pubDate>
      <guid>http://snippets.dzone.com/posts/show/5724</guid>
      <author>ki4ngel (Benoit Asselin)</author>
    </item>
    <item>
      <title>Formating monetary values</title>
      <link>http://snippets.dzone.com/posts/show/5706</link>
      <description>Formating monetary values in euro&lt;br /&gt;&lt;br /&gt;&lt;code&gt;&lt;br /&gt;&lt;?php&lt;br /&gt;&lt;br /&gt;$number = 1234.567;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;// First method&lt;br /&gt;echo sprintf('%.2f &amp;euro;', $number); // 1234.57 &#8364;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;// Second method&lt;br /&gt;echo number_format($number, 2, ',', ' ') . ' &amp;euro;'; // 1 234,57 &#8364;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;// Third method&lt;br /&gt;setlocale(LC_MONETARY, 'en_US');&lt;br /&gt;echo money_format('%n', $number); // $1,234.57&lt;br /&gt;&lt;br /&gt;setlocale(LC_MONETARY, 'fr_FR');&lt;br /&gt;echo money_format('%n', $number); // 1 234,57 Eu&lt;br /&gt;echo money_format('%!n &amp;euro;', $number); // 1 234,57 &#8364;&lt;br /&gt;&lt;br /&gt;?&gt;&lt;br /&gt;&lt;/code&gt;&lt;br /&gt;&lt;br /&gt;&lt;a href="http://www.ab-d.fr/"&gt;Retour &#224; la source: &lt;/a&gt;&lt;a href="http://www.ab-d.fr/date/2008-06-28/"&gt;Formating monetary values&lt;/a&gt;</description>
      <pubDate>Sat, 28 Jun 2008 20:04:16 GMT</pubDate>
      <guid>http://snippets.dzone.com/posts/show/5706</guid>
      <author>ki4ngel (Benoit Asselin)</author>
    </item>
    <item>
      <title>undo_magic_quotes and PHP 6</title>
      <link>http://snippets.dzone.com/posts/show/5537</link>
      <description>&lt;code&gt;&lt;br /&gt;&lt;br /&gt;if(!function_exists('get_magic_quotes_gpc')) {&lt;br /&gt;	// for PHP 6.x&lt;br /&gt;	function get_magic_quotes_gpc() { return 0; }&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;if(get_magic_quotes_gpc()) {&lt;br /&gt;	function undo_magic_quotes(&amp;$array) {&lt;br /&gt;		foreach($array as $key =&gt; $value) {&lt;br /&gt;			if(is_array($value)) {&lt;br /&gt;				undo_magic_quotes($array[$key]);&lt;br /&gt;			} else {&lt;br /&gt;				$array[$key] = stripslashes($value);&lt;br /&gt;			}&lt;br /&gt;		}&lt;br /&gt;	}&lt;br /&gt;	&lt;br /&gt;	undo_magic_quotes($_GET);&lt;br /&gt;	undo_magic_quotes($_POST);&lt;br /&gt;	undo_magic_quotes($_COOKIE);&lt;br /&gt;	undo_magic_quotes($_REQUEST);&lt;br /&gt;	undo_magic_quotes($_FILES);&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;&lt;/code&gt;&lt;br /&gt;&lt;br /&gt;&lt;a href="http://www.ab-d.fr/"&gt;Code source &lt;/a&gt;&lt;a href="http://www.ab-d.fr/date/2008-05-25/"&gt;magic_quotes and $_GET, $_POST, $_COOKIE, $_REQUEST ( php6 )&lt;/a&gt;</description>
      <pubDate>Sun, 25 May 2008 16:33:26 GMT</pubDate>
      <guid>http://snippets.dzone.com/posts/show/5537</guid>
      <author>ki4ngel (Benoit Asselin)</author>
    </item>
    <item>
      <title>parseInt() in PHP</title>
      <link>http://snippets.dzone.com/posts/show/5237</link>
      <description>&lt;code&gt;&lt;br /&gt;function parseInt($string) {&lt;br /&gt;//	return intval($string);&lt;br /&gt;	if(preg_match('/(\d+)/', $string, $array)) {&lt;br /&gt;		return $array[1];&lt;br /&gt;	} else {&lt;br /&gt;		return 0;&lt;br /&gt;	}&lt;br /&gt;}&lt;br /&gt;&lt;/code&gt;&lt;br /&gt;&lt;br /&gt;&lt;code&gt;&lt;br /&gt;echo parseInt("2008"); // 2008&lt;br /&gt;echo parseInt("99.90 dollars"); // 99&lt;br /&gt;echo parseInt("www.w3.org"); // 3&lt;br /&gt;echo parseInt("300 spartiates"); // 300&lt;br /&gt;echo parseInt("block text..."); // 0&lt;br /&gt;&lt;/code&gt;&lt;br /&gt;&lt;br /&gt;&lt;a href="http://www.ab-d.fr/"&gt;Source: AB-D Cr&#233;ation de sites internet&lt;/a&gt;</description>
      <pubDate>Sun, 16 Mar 2008 15:39:02 GMT</pubDate>
      <guid>http://snippets.dzone.com/posts/show/5237</guid>
      <author>ki4ngel (Benoit Asselin)</author>
    </item>
    <item>
      <title>Make a variable CSS</title>
      <link>http://snippets.dzone.com/posts/show/5110</link>
      <description>Page.html&lt;br /&gt;&lt;code&gt;&lt;br /&gt;&lt;!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"&lt;br /&gt;	"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"&gt;&lt;br /&gt;&lt;br /&gt;&lt;html xmlns="http://www.w3.org/1999/xhtml" xml:lang="fr" lang="fr"&gt;&lt;br /&gt;&lt;head&gt;&lt;br /&gt;	&lt;meta http-equiv="Content-Type" content="text/html; charset=utf-8"/&gt;&lt;br /&gt;	&lt;br /&gt;	&lt;title&gt;Variable CSS&lt;/title&gt;&lt;br /&gt;	&lt;link rel="stylesheet" type="text/css" href="style.php" /&gt;&lt;br /&gt;&lt;/head&gt;&lt;br /&gt;&lt;br /&gt;&lt;body&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;h1&gt;Title&lt;/h1&gt;&lt;br /&gt;&lt;br /&gt;&lt;p class="color-1"&gt; Text  Text  Text  &lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;p class="color-2"&gt; Text  Text  Text  &lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;p class="color-3"&gt; Text  Text  Text  &lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;/body&gt;&lt;br /&gt;&lt;br /&gt;&lt;/html&gt;&lt;br /&gt;&lt;/code&gt;&lt;br /&gt;&lt;br /&gt;Style.php&lt;br /&gt;&lt;code&gt;&lt;br /&gt;&lt;?php&lt;br /&gt;header('Content-Type: text/css');&lt;br /&gt;&lt;br /&gt;$color_0 = '#000000';&lt;br /&gt;$color_1 = '#ff0000';&lt;br /&gt;$color_2 = '#ff3300';&lt;br /&gt;$color_3 = '#ff6600';&lt;br /&gt;&lt;br /&gt;?&gt;&lt;br /&gt;&lt;br /&gt;* { font-family: sans-serif; }&lt;br /&gt;&lt;br /&gt;h1 {&lt;br /&gt;	padding: 5px;&lt;br /&gt;	color: &lt;?= $color_0 ?&gt;;&lt;br /&gt;	border: 5px solid &lt;?= $color_2 ?&gt;;&lt;br /&gt;	background-color: &lt;?= $color_3 ?&gt;;&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;p.color-1 { color: &lt;?= $color_1 ?&gt;; }&lt;br /&gt;p.color-2 { color: &lt;?= $color_2 ?&gt;; font-weight: bold; }&lt;br /&gt;p.color-3 { color: &lt;?= $color_3 ?&gt;; font-style: italic; }&lt;br /&gt;&lt;/code&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;a href="http://www.ab-d.fr"&gt;Source: Asselin Benoit D&#233;veloppement, cr&#233;ation de site internet amiens&lt;/a&gt;</description>
      <pubDate>Wed, 06 Feb 2008 19:02:03 GMT</pubDate>
      <guid>http://snippets.dzone.com/posts/show/5110</guid>
      <author>ki4ngel (Benoit Asselin)</author>
    </item>
    <item>
      <title>count() in JavaScript</title>
      <link>http://snippets.dzone.com/posts/show/4865</link>
      <description>The same function as &lt;a href="http://www.php.net/count"&gt;count()&lt;/a&gt; in php.&lt;br /&gt;&lt;br /&gt;&lt;code&gt;&lt;br /&gt;Array.prototype.count = function() {&lt;br /&gt;	return this.length;&lt;br /&gt;};&lt;br /&gt;&lt;/code&gt;&lt;br /&gt;&lt;br /&gt;Sample :&lt;br /&gt;&lt;code&gt;&lt;br /&gt;var v_array = [ 5, 10, 15, 20, 25];&lt;br /&gt;document.writeln(v_array.count());  // 5&lt;br /&gt;&lt;/code&gt;&lt;br /&gt;&lt;br /&gt;&lt;a href="http://www.ab-d.fr/"&gt;Source: AB-D.fr&lt;/a&gt;</description>
      <pubDate>Sat, 08 Dec 2007 13:11:46 GMT</pubDate>
      <guid>http://snippets.dzone.com/posts/show/4865</guid>
      <author>ki4ngel (Benoit Asselin)</author>
    </item>
    <item>
      <title>Some problems with charset in UTF-8 ?</title>
      <link>http://snippets.dzone.com/posts/show/4814</link>
      <description>So you can use this request MySQL before all others, for fix your problems :&lt;br /&gt;&lt;code&gt;&lt;br /&gt;...&lt;br /&gt;mysql_query( "SET NAMES 'utf8' " );&lt;br /&gt;...&lt;br /&gt;&lt;/code&gt;&lt;br /&gt;&lt;br /&gt;&lt;a href="http://www.ab-d.fr/"&gt;Source: ab-d.fr&lt;br /&gt;Languages: PHP and MySQL&lt;/a&gt;</description>
      <pubDate>Fri, 23 Nov 2007 22:07:58 GMT</pubDate>
      <guid>http://snippets.dzone.com/posts/show/4814</guid>
      <author>ki4ngel (Benoit Asselin)</author>
    </item>
    <item>
      <title>Use get_magic_quotes_gpc();</title>
      <link>http://snippets.dzone.com/posts/show/4795</link>
      <description>&lt;code&gt;&lt;br /&gt;function f_magic_quotes($text) {&lt;br /&gt;	if ( !get_magic_quotes_gpc() ) {&lt;br /&gt;		return addslashes($text);&lt;br /&gt;	} else {&lt;br /&gt;		return $text;&lt;br /&gt;	}&lt;br /&gt;}&lt;br /&gt;&lt;/code&gt;&lt;br /&gt;&lt;br /&gt;&lt;code&gt;&lt;br /&gt;function f_clean_quotes($text) {&lt;br /&gt;	if ( !get_magic_quotes_gpc() ) {&lt;br /&gt;		return $text;&lt;br /&gt;	} else {&lt;br /&gt;		return stripslashes($text);&lt;br /&gt;	}&lt;br /&gt;}&lt;br /&gt;&lt;/code&gt;&lt;br /&gt;&lt;br /&gt;&lt;a href="http://www.ab-d.fr/"&gt;Source: ab-d&lt;/a&gt;&lt;br /&gt;</description>
      <pubDate>Sun, 18 Nov 2007 20:57:07 GMT</pubDate>
      <guid>http://snippets.dzone.com/posts/show/4795</guid>
      <author>ki4ngel (Benoit Asselin)</author>
    </item>
    <item>
      <title>Write a variable PHP with spaces or accents</title>
      <link>http://snippets.dzone.com/posts/show/4685</link>
      <description>Write a variable PHP with spaces or accents&lt;br /&gt;&lt;br /&gt;&lt;code&gt;&lt;br /&gt;&lt;?php&lt;br /&gt;&lt;br /&gt;${'New variable text'} = 'This is a new variable text.';&lt;br /&gt;&lt;br /&gt;echo ${'New variable text'};&lt;br /&gt;// This is a new variable text.&lt;br /&gt;&lt;br /&gt;?&gt;&lt;br /&gt;&lt;/code&gt;&lt;br /&gt;&lt;br /&gt;&lt;a href="http://www.ab-d.fr/"&gt;Source: ab-d&lt;/a&gt;</description>
      <pubDate>Mon, 22 Oct 2007 08:04:24 GMT</pubDate>
      <guid>http://snippets.dzone.com/posts/show/4685</guid>
      <author>ki4ngel (Benoit Asselin)</author>
    </item>
  </channel>
</rss>
