<?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>Thu, 18 Nov 2010 10:46:30 +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>file_get_contents</title>
		<link>http://www.phptoruby.com/file_get_contents</link>
		<comments>http://www.phptoruby.com/file_get_contents#comments</comments>
		<pubDate>Thu, 18 Nov 2010 10:45:24 +0000</pubDate>
		<dc:creator>RubyLove</dc:creator>
		
		<category><![CDATA[PHP]]></category>

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

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

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

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

		<guid isPermaLink="false">http://www.phptoruby.com/file_get_contents</guid>
		<description><![CDATA[The file_get_contents() function in PHP reads the content of a file into a string (or reads the HTML of a web page into a string).
PHP

$body = file_get_contents&#40; 'http://www.google.com' &#41;;
echo $body;
&#160;
/* 
... HTML source of www.google.com ...
*/

To replicate this functionality in Ruby, we will use the Net/HTTP class from Ruby.
Ruby

require 'net/http';
uri = 'http://www.google.com';
body = Net::HTTP.get_response&#40;URI.parse&#40;self&#41;&#41;.body;
&#160;
p result
# [...]]]></description>
		<wfw:commentRss>http://www.phptoruby.com/file_get_contents/feed</wfw:commentRss>
		</item>
		<item>
		<title>array_fill_keys</title>
		<link>http://www.phptoruby.com/array_fill_keys</link>
		<comments>http://www.phptoruby.com/array_fill_keys#comments</comments>
		<pubDate>Thu, 11 Nov 2010 13:02:28 +0000</pubDate>
		<dc:creator>RubyLove</dc:creator>
		
		<category><![CDATA[PHP]]></category>

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

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

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

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

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

		<guid isPermaLink="false">http://www.phptoruby.com/array_fill_keys</guid>
		<description><![CDATA[The array_fill_keys() function in PHP allows you to populate the values of an array while specifying its keys.
PHP

$keys = array&#40;'write', 'debug', 'execute'&#41;;
$result = array_fill_keys&#40;$keys, 'code'&#41;;
var_export&#40;$result&#41;;
// =&#62; array('write' =&#62; 'code', 'debug' =&#62; 'code', 'execute' =&#62; 'code')

To replicate this functionality in Ruby, we need to use a Hash object, since arrays in Ruby don’t use associative key/value [...]]]></description>
		<wfw:commentRss>http://www.phptoruby.com/array_fill_keys/feed</wfw:commentRss>
		</item>
		<item>
		<title>array_merge</title>
		<link>http://www.phptoruby.com/array_merge</link>
		<comments>http://www.phptoruby.com/array_merge#comments</comments>
		<pubDate>Tue, 19 Oct 2010 11:01:02 +0000</pubDate>
		<dc:creator>RubyLove</dc:creator>
		
		<category><![CDATA[PHP]]></category>

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

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

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

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

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

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

		<guid isPermaLink="false">http://www.phptoruby.com/array_merge</guid>
		<description><![CDATA[The array_merge() function in PHP merges 2 arrays by appending the second array onto the first array, and returning the resulting array.
The way to do this in Ruby depends on the type of data - if dealing with associative arrays (known as a hash in Ruby), we can use the merge() method of the Ruby [...]]]></description>
		<wfw:commentRss>http://www.phptoruby.com/array_merge/feed</wfw:commentRss>
		</item>
		<item>
		<title>array_fill</title>
		<link>http://www.phptoruby.com/array_fill</link>
		<comments>http://www.phptoruby.com/array_fill#comments</comments>
		<pubDate>Wed, 13 Oct 2010 11:16:39 +0000</pubDate>
		<dc:creator>RubyLove</dc:creator>
		
		<category><![CDATA[PHP]]></category>

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

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

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

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

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

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

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

		<guid isPermaLink="false">http://www.phptoruby.com/array_fill</guid>
		<description><![CDATA[The array_fill() function in PHP allows an array to be populated (i.e. filled) with a particular value.
PHP

$a = array_fill&#40;3, 5, 'php'&#41;;
print_r&#40;$a&#41;;
/*
Array (
	[3] =&#62; php
	[4] =&#62; php
	[5] =&#62; php
	[6] =&#62; php
	[7] =&#62; php
)
*/

In Ruby this is not really possible because Ruby arrays must have their keys filled in the correct order, i.e. you cant skip assigning [...]]]></description>
		<wfw:commentRss>http://www.phptoruby.com/array_fill/feed</wfw:commentRss>
		</item>
		<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>
	</channel>
</rss>
