<?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>kwatog &#187; PHP</title>
	<atom:link href="http://kwatog.com/category/blog/php/feed/" rel="self" type="application/rss+xml" />
	<link>http://kwatog.com</link>
	<description>tech notes and general nonsense</description>
	<lastBuildDate>Thu, 29 Jul 2010 12:06:02 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0</generator>
		<item>
		<title>Adding New Array Key in PHP</title>
		<link>http://kwatog.com/blog/php/adding-new-array-key-in-php/</link>
		<comments>http://kwatog.com/blog/php/adding-new-array-key-in-php/#comments</comments>
		<pubDate>Sat, 03 Apr 2010 00:34:00 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[array_fill_keys]]></category>
		<category><![CDATA[array_key_exists]]></category>
		<category><![CDATA[array_merge]]></category>
		<category><![CDATA[programming]]></category>

		<guid isPermaLink="false">http://kwatog.com/?p=250</guid>
		<description><![CDATA[In adding a new array key, we&#8217;ll need to know two array functions called array_key_exists and array_merge. First, let&#8217;s take a look at array_keys. It&#8217;s a function that returns an array containing the keys of an array. &#60;?php $a = array("foo"=>"1","bar" => "2"); $keys = array_keys($a); print_r($keys); ?&#62; Second, of course, is array_merge. As the [...]]]></description>
			<content:encoded><![CDATA[<p>In adding a new array key, we&#8217;ll need  to know two array functions called <em>array_key_exists</em> and <em>array_merge</em>.</p>
<p>First, let&#8217;s take a look at <strong>array_keys</strong>. It&#8217;s a function that returns an array containing the keys of an array.<br />
<code><br />
&lt;?php<br />
    $a = array("foo"=>"1","bar" => "2");<br />
    $keys = array_keys($a);</p>
<p>   print_r($keys);<br />
?&gt;<br />
</code></p>
<p>Second, of course, is <strong>array_merge</strong>. As the name implies, it just merge the two array.<br />
<code><br />
&lt;?php<br />
  $a = array("foo" => "1", "bar" = "2");<br />
  $b = array("name" => "Juan", "gender" => "male");<br />
  $c = array_merge($b, $a);</p>
<p> print_r($c);<br />
?&gt;<br />
</code></p>
<p>So here&#8217;s the final code we have.<br />
<code><br />
&lt;?php<br />
  $a = array("foo" => "1", "bar" = "2");<br />
  // keys to be added<br />
  $b =array("name" => "Juan");<br />
  $c =array("gender" => "male");  </p>
<p>  $a = array_merge($a, $b, $c);</p>
<p>  print_r($a);</p>
<p>?&gt;<br />
</code></p>
<p>The code above is too simplistic ( <em>we didn&#8217;t even use the array_keys function</em>) but if you are not certain with the keys you of the array to be merged, then this functions become handy. Example as below.<br />
<code><br />
&lt;?php<br />
  $a = array("foo" => "1", "bar" = "2");<br />
  /* let's say $b comes from a function that returns<br />
     array with (i.e, array("name" => "Juan", "gender" => "male"))<br />
  */<br />
  $b = my_function_ret_array();</p>
<p>  $keys = array_keys($b);<br />
  foreach($keys as $key){<br />
      if(array_key_exists($key, $a){<br />
          $a[$key] = $b[$key];<br />
       }<br />
      else {<br />
          $a = array_merge($a, array($key => $b[$key]));<br />
     }<br />
  }</p>
<p>  print_r($a);</p>
<p>?&gt;<br />
</code></p>
<p>Again, I must remind my readers that there might be better way of doing this. It all depends on the situation and for the time being, this is the functions I used. If you want to suggest a new one, please share it in the comment box.</p>
]]></content:encoded>
			<wfw:commentRss>http://kwatog.com/blog/php/adding-new-array-key-in-php/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>How to Find PHP.INI Path</title>
		<link>http://kwatog.com/blog/linux/how-to-find-php-ini-path/</link>
		<comments>http://kwatog.com/blog/linux/how-to-find-php-ini-path/#comments</comments>
		<pubDate>Sun, 06 Sep 2009 04:36:58 +0000</pubDate>
		<dc:creator>kwatog</dc:creator>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[PHP]]></category>

		<guid isPermaLink="false">http://kwatog.com/?p=143</guid>
		<description><![CDATA[If you can&#8217;t find it in /etc/php.ini, then you have to use ssh and execute the command below. php -i &#124; grep php.ini The command will return something like Configuration File (php.ini) Path => /etc/php.ini]]></description>
			<content:encoded><![CDATA[<p>If you can&#8217;t find it in /etc/php.ini, then you have to use ssh and execute the command below.<br />
<code>php -i | grep php.ini</code></p>
<p>The command will return something like<br />
<strong>Configuration File (php.ini) Path => /etc/php.ini<br />
</strong></p>
]]></content:encoded>
			<wfw:commentRss>http://kwatog.com/blog/linux/how-to-find-php-ini-path/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
