<?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/"
	>

<channel>
	<title>PHP to Ruby</title>
	<atom:link href="http://www.phptoruby.com/feed" rel="self" type="application/rss+xml" />
	<link>http://www.phptoruby.com</link>
	<description>Convert PHP code into Ruby!</description>
	<pubDate>Mon, 05 Jul 2010 23:17:47 +0000</pubDate>
	<generator>http://wordpress.org/?v=2.7.1</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>array_flip</title>
		<link>http://www.phptoruby.com/array_flip</link>
		<comments>http://www.phptoruby.com/array_flip#comments</comments>
		<pubDate>Mon, 19 Apr 2010 07:03:12 +0000</pubDate>
		<dc:creator>RubyLove</dc:creator>
		
		<category><![CDATA[PHP]]></category>

		<category><![CDATA[Ruby]]></category>

		<category><![CDATA[arrays]]></category>

		<category><![CDATA[array_flip]]></category>

		<category><![CDATA[elements]]></category>

		<category><![CDATA[invert]]></category>

		<guid isPermaLink="false">http://www.phptoruby.com/array_flip</guid>
		<description><![CDATA[The array_flip() PHP function changes all the keys in an array into values, and all the values into keys.
PHP

$a = array&#40;'apple' =&#62; 1, 'ibm' =&#62; 2, 'sun' =&#62; 3&#41;;
$flipped = array_flip&#40;$a&#41;;
print_r&#40;$flipped&#41;;
/*
Array (
	[1] =&#62; apple
	[2] =&#62; ibm
	[3] =&#62; sun
)
*/

To replicate this functionality in Ruby, we will use a Hash object, since arrays in Ruby don’t use [...]]]></description>
		<wfw:commentRss>http://www.phptoruby.com/array_flip/feed</wfw:commentRss>
		</item>
		<item>
		<title>call_user_func</title>
		<link>http://www.phptoruby.com/call_user_func</link>
		<comments>http://www.phptoruby.com/call_user_func#comments</comments>
		<pubDate>Sat, 27 Mar 2010 09:07:01 +0000</pubDate>
		<dc:creator>RubyLove</dc:creator>
		
		<category><![CDATA[PHP]]></category>

		<category><![CDATA[Ruby]]></category>

		<category><![CDATA[call_user_func]]></category>

		<category><![CDATA[send]]></category>

		<guid isPermaLink="false">http://www.phptoruby.com/call_user_func</guid>
		<description><![CDATA[The call_user_func() function in PHP calls a user defined function as specified by the first parameter. You can also use call_user_func() to call an instance method of an object by using an array(instance, methodName) parameter as follows:
PHP

class User&#123;
  private $name = null;
&#160;
  public function __construct&#40;$name&#41;&#123;
     $this-&#62;name = $name;
  [...]]]></description>
		<wfw:commentRss>http://www.phptoruby.com/call_user_func/feed</wfw:commentRss>
		</item>
		<item>
		<title>array_keys</title>
		<link>http://www.phptoruby.com/array_keys</link>
		<comments>http://www.phptoruby.com/array_keys#comments</comments>
		<pubDate>Wed, 24 Feb 2010 12:31:01 +0000</pubDate>
		<dc:creator>RubyLove</dc:creator>
		
		<category><![CDATA[PHP]]></category>

		<category><![CDATA[Ruby]]></category>

		<category><![CDATA[arrays]]></category>

		<category><![CDATA[array_keys]]></category>

		<category><![CDATA[elements]]></category>

		<guid isPermaLink="false">http://www.phptoruby.com/array_keys</guid>
		<description><![CDATA[The array_keys() function in PHP takes an array as it&#8217;s argument and returns all the keys in that array (as a numeric array).
PHP

$array = array&#40;'go' =&#62; 'green', 'stop' =&#62; 'red'&#41;;
var_dump&#40; array_keys&#40;$array&#41; &#41;;
/*
Array (
	[0] =&#62; go
	[1] =&#62; stop
)
*/

To replicate this functionality in Ruby, we need to use a Hash object, since arrays in Ruby don’t use [...]]]></description>
		<wfw:commentRss>http://www.phptoruby.com/array_keys/feed</wfw:commentRss>
		</item>
		<item>
		<title>array_product</title>
		<link>http://www.phptoruby.com/array_product</link>
		<comments>http://www.phptoruby.com/array_product#comments</comments>
		<pubDate>Wed, 17 Feb 2010 11:38:14 +0000</pubDate>
		<dc:creator>RubyLove</dc:creator>
		
		<category><![CDATA[PHP]]></category>

		<category><![CDATA[Ruby]]></category>

		<category><![CDATA[arrays]]></category>

		<category><![CDATA[array_product]]></category>

		<category><![CDATA[multiply]]></category>

		<guid isPermaLink="false">http://www.phptoruby.com/array_product</guid>
		<description><![CDATA[The array_product() PHP function returns the product of all values in an array. In other words, it multiplies all values in the array together, and returns the result as a number.
PHP

$a = array&#40;'1', '2', '3'&#41;;
$product_total = array_product&#40;$a&#41;;
echo $product_total;
// =&#62; 6

Ruby

a = &#91; &#34;1&#34;, &#34;2&#34;, &#34;3&#34; &#93;;
product_total = a.inject &#123;&#124;product, element&#124; product * element &#125;
puts product_total;
# [...]]]></description>
		<wfw:commentRss>http://www.phptoruby.com/array_product/feed</wfw:commentRss>
		</item>
		<item>
		<title>array_rand</title>
		<link>http://www.phptoruby.com/array_rand</link>
		<comments>http://www.phptoruby.com/array_rand#comments</comments>
		<pubDate>Tue, 16 Feb 2010 15:18:42 +0000</pubDate>
		<dc:creator>RubyLove</dc:creator>
		
		<category><![CDATA[PHP]]></category>

		<category><![CDATA[Ruby]]></category>

		<category><![CDATA[arrays]]></category>

		<category><![CDATA[array_rand]]></category>

		<category><![CDATA[elements]]></category>

		<category><![CDATA[rand]]></category>

		<category><![CDATA[random]]></category>

		<category><![CDATA[randomize]]></category>

		<guid isPermaLink="false">http://www.phptoruby.com/array_rand</guid>
		<description><![CDATA[The array_rand() function in PHP randomly selects one or more elements from an array.
PHP

$users = array&#40;'john', 'jane', 'tim', 'alex'&#41;;
$lucky_winner = array_rand&#40;$users&#41;;
echo $lucky_winner;
// alex

Ruby

users = &#91; 'john', 'jane', 'tim', 'alex' &#93;;
lucky_winner = users&#91;rand&#40;users.length&#41;&#93;;
puts lucky_winner;
# =&#62; alex

]]></description>
		<wfw:commentRss>http://www.phptoruby.com/array_rand/feed</wfw:commentRss>
		</item>
		<item>
		<title>array_reverse</title>
		<link>http://www.phptoruby.com/array_reverse</link>
		<comments>http://www.phptoruby.com/array_reverse#comments</comments>
		<pubDate>Sun, 25 Oct 2009 14:45:16 +0000</pubDate>
		<dc:creator>RubyLove</dc:creator>
		
		<category><![CDATA[PHP]]></category>

		<category><![CDATA[Ruby]]></category>

		<category><![CDATA[arrays]]></category>

		<category><![CDATA[array_reverse]]></category>

		<category><![CDATA[elements]]></category>

		<guid isPermaLink="false">http://www.phptoruby.com/array_reverse</guid>
		<description><![CDATA[The array_reverse() function in PHP reverses the order of the elements in an array.
PHP

$a = array&#40;'php', 'ruby', 'java'&#41;;
$results = array_reverse&#40;$a&#41;;
print_r&#40;$results&#41;;
/*
Array (
	[0] =&#62; 'java'
	[1] =&#62; 'ruby'
	[2] =&#62; 'php'
)
*/

To replicate this functionality in Ruby, we can use the reverse method of the Array object.
Ruby

a = &#91; &#34;php&#34;, &#34;ruby&#34;, &#34;java&#34; &#93;;
p a.reverse;
# =&#62; [&#34;java&#34;, &#34;ruby&#34;, &#34;php&#34;]

]]></description>
		<wfw:commentRss>http://www.phptoruby.com/array_reverse/feed</wfw:commentRss>
		</item>
		<item>
		<title>array_count_values</title>
		<link>http://www.phptoruby.com/array_count_values</link>
		<comments>http://www.phptoruby.com/array_count_values#comments</comments>
		<pubDate>Wed, 21 Oct 2009 15:49:03 +0000</pubDate>
		<dc:creator>RubyLove</dc:creator>
		
		<category><![CDATA[PHP]]></category>

		<category><![CDATA[Ruby]]></category>

		<category><![CDATA[arrays]]></category>

		<category><![CDATA[array_count_values]]></category>

		<category><![CDATA[elements]]></category>

		<guid isPermaLink="false">http://www.phptoruby.com/array_count_values</guid>
		<description><![CDATA[The array_count_values() function in PHP counts the number of instances of each value in an array. array_count_values() returns an associative array using the values of the input array as keys and their frequency in the input as values.
PHP

$a = array&#40;'a', 'b','a', 'c', 'c'&#41;;
$results = array_count_values&#40;$a&#41;;
print_r&#40;$results&#41;;
/*
Array (
	[a] =&#62; 2
	[b] =&#62; 1
	[c] =&#62; 2
)
*/

To replicate this functionality [...]]]></description>
		<wfw:commentRss>http://www.phptoruby.com/array_count_values/feed</wfw:commentRss>
		</item>
		<item>
		<title>array_chunk</title>
		<link>http://www.phptoruby.com/array_chunk</link>
		<comments>http://www.phptoruby.com/array_chunk#comments</comments>
		<pubDate>Sat, 17 Oct 2009 14:37:28 +0000</pubDate>
		<dc:creator>RubyLove</dc:creator>
		
		<category><![CDATA[PHP]]></category>

		<category><![CDATA[Ruby]]></category>

		<category><![CDATA[arrays]]></category>

		<category><![CDATA[array_chunk]]></category>

		<category><![CDATA[elements]]></category>

		<category><![CDATA[multidimensional array]]></category>

		<guid isPermaLink="false">http://www.phptoruby.com/array_chunk</guid>
		<description><![CDATA[The array_chunk() function in PHP splits an array into multiple smaller arrays (array chunks).
PHP

$langs = array&#40;'php', 'ruby', 'java', 'perl', 'csharp'&#41;;
$my_size = 2;
var_dump&#40; array_chunk&#40;$langs, $my_size&#41; &#41;;
&#160;
/*
Array (
    [0] =&#62; Array
        (
            [0] =&#62; php
  [...]]]></description>
		<wfw:commentRss>http://www.phptoruby.com/array_chunk/feed</wfw:commentRss>
		</item>
		<item>
		<title>array_shift</title>
		<link>http://www.phptoruby.com/array_shift</link>
		<comments>http://www.phptoruby.com/array_shift#comments</comments>
		<pubDate>Wed, 14 Oct 2009 15:34:00 +0000</pubDate>
		<dc:creator>RubyLove</dc:creator>
		
		<category><![CDATA[PHP]]></category>

		<category><![CDATA[Ruby]]></category>

		<category><![CDATA[arrays]]></category>

		<category><![CDATA[array_shift]]></category>

		<category><![CDATA[elements]]></category>

		<guid isPermaLink="false">http://www.phptoruby.com/array_shift</guid>
		<description><![CDATA[The array_shift() function in PHP removes an element from the beginning of an array and returns it.
PHP

$my_array = array&#40;'a', 'b', 'c', 'd'&#41;;
$my_element = array_shift&#40;$my_array&#41;;
print_r&#40;$my_element&#41;;
/*
Array (
	[0] =&#62; a
)
*/

Ruby

my_array = &#91; &#34;a&#34;, &#34;b&#34;, &#34;c&#34;, &#34;d&#34; &#93;;
puts my_array.shift;
# =&#62; [&#34;a&#34;]

]]></description>
		<wfw:commentRss>http://www.phptoruby.com/array_shift/feed</wfw:commentRss>
		</item>
		<item>
		<title>array_unique</title>
		<link>http://www.phptoruby.com/array_unique</link>
		<comments>http://www.phptoruby.com/array_unique#comments</comments>
		<pubDate>Sat, 10 Oct 2009 13:49:36 +0000</pubDate>
		<dc:creator>RubyLove</dc:creator>
		
		<category><![CDATA[PHP]]></category>

		<category><![CDATA[Ruby]]></category>

		<category><![CDATA[arrays]]></category>

		<category><![CDATA[array_unique]]></category>

		<category><![CDATA[elements]]></category>

		<category><![CDATA[uniq]]></category>

		<category><![CDATA[values]]></category>

		<guid isPermaLink="false">http://www.phptoruby.com/array_unique</guid>
		<description><![CDATA[The array_unique() function in PHP takes an array and filters our any duplicates values, returning the array with only unique values present.
PHP

$elements = array&#40;'php', 'ruby', 'perl', 'php'&#41;;
array_unique&#40;$elements&#41;;
print_r&#40;$elements&#41;;
/*
Array (
	[0] =&#62; php
	[1] =&#62; ruby
	[2] =&#62; perl
)
*/

Ruby

elements = &#91; &#34;php&#34;, &#34;ruby&#34;, &#34;perl&#34;, &#34;php&#34; &#93;;
puts elements.uniq;
# =&#62; [&#34;php&#34;, &#34;ruby&#34;, &#34;perl&#34;]

]]></description>
		<wfw:commentRss>http://www.phptoruby.com/array_unique/feed</wfw:commentRss>
		</item>
	</channel>
</rss>
