-
Associative Array
Posted on September 22nd, 2009 No commentsAssociative Array
-
PHP Array
Posted on September 20th, 2009 No commentsA PHP array can be thought of as a variable which can store multiple other variables. Every item in a PHP array is known as an element and is composed of a key and a value. There are 2 main types of PHP arrays:
- Numeric Array
- Associative Array
Each of these can in turn be a Multidimensional Array.
Example Numeric Array:
$terms = array('array', 'element', 'key', 'value'); var_dump($terms); /* => Array ( [0] => array [1] => element [2] => key [3] => value ) */
Example Associative Array:
$terms = array( 'term1' => 'array', 'term2' => 'element', 'term3' => 'key', 'term4' => 'value' ); var_dump($terms); /* => Array ( [term1] => array [term2] => element [term3] => key [term4] => value ) */
Find out more information about PHP’s Numeric Array, Associative Array or Multidimensional Array.
-
crc32
Posted on September 17th, 2009 1 commentThe crc32() function in PHP generates the cyclic redundancy checksum (CRC) polynomial of 32-bit lengths of a string, and returns it as an integer.
PHP
$checksum = crc32('hello world'); echo $checksum; // => 222957957
Ruby
require 'zlib'; puts Zlib.crc32('hello world'); # => 222957957
-
reset
Posted on September 14th, 2009 No commentsThe reset() function in PHP sets the internal pointer of an array to its first element. However in Ruby, there is no internal array pointer - as such Ruby doesn’t have an equivalent to PHP’s reset() function.
-
pos
Posted on September 11th, 2009 No commentsThe pos() function is only an alias of current, which returns the key and value of the element the current array pointer is pointing to. However since Ruby doesn’t have an internal array pointer, this function does not have a Ruby equivalent.
For further information about pos(), see current().
-
current
Posted on September 8th, 2009 No commentsThe current() function in PHP returns the key and value of the element the current array pointer is pointing to. However in Ruby, there is no internal array pointer - as such Ruby doesn’t have an equivalent to PHP’s current() function.
-
key
Posted on September 5th, 2009 No commentsThe key() function in PHP returns the index element of the element the current array pointer is pointing to. However in Ruby, there is no internal array pointer - as such Ruby doesn’t have an equivalent to PHP’s key() function.
-
end
Posted on September 2nd, 2009 No commentsThe end() function in PHP moves the internal array pointer to the last element in the array. However in Ruby, there is no internal array pointer - as such Ruby doesn’t have an equivalent to PHP’s end() function. However Ruby does have the Array::last() method which returns the last element of an array.
PHP
$programming = array('java', 'ruby', 'python', 'php'); $language = end($programming); print_r($language); // => php
Ruby
programming = ['java', 'ruby', 'python', 'php']; language = programming.last; puts language; => # php
-
next
Posted on August 30th, 2009 No commentsThe next() function in PHP moves the internal array pointer one place forward. However in Ruby, there is no internal array pointer - as such Ruby doesn’t have an equivalent to PHP’s next() function.
-
prev
Posted on August 27th, 2009 No commentsThe prev() function in PHP moves the internal array pointer to the previous element (rewinds). However in Ruby, there is no internal array pointer - as such Ruby doesn’t have an equivalent to PHP’s prev() function.


