This Is A Custom Widget

This Sliding Bar can be switched on or off in theme options, and can take any widget you throw at it or even fill it with your custom HTML Code. Its perfect for grabbing the attention of your viewers. Choose between 1, 2, 3 or 4 columns, set the background color, widget divider color, activate transparency, a top border or fully disable it on desktop and mobile.

This Is A Custom Widget

This Sliding Bar can be switched on or off in theme options, and can take any widget you throw at it or even fill it with your custom HTML Code. Its perfect for grabbing the attention of your viewers. Choose between 1, 2, 3 or 4 columns, set the background color, widget divider color, activate transparency, a top border or fully disable it on desktop and mobile.
7 10, 2009

array_unshift

By | 2009-10-16T08:08:17+00:00 October 7th, 2009|Categories: PHP, Ruby|Tags: , , , |Comments Off on array_unshift

The array_unshift() function in PHP prepends elements onto the beginning of an array.

PHP

$cue = array('http', 'https', 'ftp');
array_unshift($cue, 'ssh');
print_r($cue);
/*
Array (
	[0] => ssh
	[1] => http
	[2] => https
	[3] => ftp
)
*/

Ruby has an identical Array method, named unshift:

Ruby

cue = [ "http", "https", "ftp" ];
cue.unshift('ssh');
puts cue;
# => [ "ssh", "http", "https", "ftp"]
1 10, 2009

list

By | 2009-10-15T22:36:18+00:00 October 1st, 2009|Categories: PHP, Ruby|Tags: , , , , , , |Comments Off on list

The list() function in PHP is used to assign multiple variables as if they were an array. Technically, list() is not a function in PHP, it is a language construct.

Ruby has no real need for a function such as list(), as the same can be achieve using parallel assignment – i.e. assigning comma separated variables to elements of an array using the normal assignment operator.

PHP

$langs = array('php', 'ruby', 'perl');
list($lang1, $lang2, $lang3) = $langs;
echo $lang1;	// php
echo $lang2;	// ruby
echo $lang3;	// perl

Ruby

langs = [ "php", "ruby", "perl" ];
lang1, lang2, lang3 = langs;
puts lang1;	# php
puts lang2;	# ruby
puts lang3;	# perl
28 09, 2009

in_array

By | 2009-10-14T13:03:32+00:00 September 28th, 2009|Categories: PHP, Ruby|Tags: , , , |Comments Off on in_array

The in_array() function in PHP checks if a value exists in an array – returning true if it does, or false otherwise.

The last argument in this function forces a strict type check of the value in PHP. Since Ruby does not consider a Fixnum of 1 and a String of ‘1’ to be the same – it always operates as if the last argument were set to true.

PHP

$my_array = array('a', 'b', 'c', 'd');
if('a', in_array($a), true) {
	echo 'Found it in the array';
}
// => Found it in the array

Ruby

my_array = [ "a", "b", "c", "d" ];
if( my_array.include?('a') ) {
	 puts 'Found it in the array';
}
# => Found it in the array
14 09, 2009

reset

By | 2009-10-15T22:36:48+00:00 September 14th, 2009|Categories: PHP, Ruby|Tags: , , , |Comments Off on reset

The 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.

11 09, 2009

pos

By | 2009-09-21T13:31:16+00:00 September 11th, 2009|Categories: PHP, Ruby|Tags: , , , , |Comments Off on pos

The 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().

8 09, 2009

current

By | 2009-10-15T22:38:27+00:00 September 8th, 2009|Categories: PHP, Ruby|Tags: , , , |Comments Off on current

The 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.

5 09, 2009

key

By | 2009-10-15T22:38:46+00:00 September 5th, 2009|Categories: PHP, Ruby|Tags: , , , |Comments Off on key

The 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.

2 09, 2009

end

By | 2009-10-15T22:39:02+00:00 September 2nd, 2009|Categories: PHP, Ruby|Tags: , , , , |Comments Off on end

The 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
30 08, 2009

next

By | 2009-10-15T22:39:14+00:00 August 30th, 2009|Categories: PHP, Ruby|Tags: , , , |Comments Off on next

The 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.

27 08, 2009

prev

By | 2009-10-15T22:39:46+00:00 August 27th, 2009|Categories: PHP, Ruby|Tags: , , , |Comments Off on prev

The 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.