19 06, 2009

rtrim

By | 2009-06-18T15:32:19+00:00 June 19th, 2009|Categories: PHP, Ruby|Tags: , , , , , , |Comments Off on rtrim

The rtrim function strips whitespace (or other characters) from the end of a string.

PHP

echo rtrim('Work Hard. Play Harder.', ' Play Harder.');
=> // 'Work Hard.'

Ruby

substitute = 'Play Harder.';

puts "Work Hard. Play Harder.".gsub(/[#{substitute}]+$/, '')
=> # 'Work Hard.'
16 06, 2009

ltrim

By | 2009-06-18T15:26:12+00:00 June 16th, 2009|Categories: PHP, Ruby|Tags: , , , , , , |Comments Off on ltrim

The ltrim function strips whitespace (or other characters) from the beginning of a string.

PHP

echo ltrim('John and I love icecream', 'John and ');
=> // 'I love icecream'

Ruby

substitute = 'John and ';

puts "John and I love icecream".gsub(/^[#{substitute}]+/, '')
=> # 'I love icecream'
13 06, 2009

trim

By | 2009-06-12T17:26:40+00:00 June 13th, 2009|Categories: PHP, Ruby|Tags: , , , , , , |Comments Off on trim

The trim function is mainly used to remove whitespace from the beginning and end of strings, although it can be used to remove other characters too.

PHP

echo trim("  Hello World  ");
=> // 'Hello World'

Ruby

puts "  Hello World  ".strip
=> # 'Hello World'

The trim() function can also take a second argument which allows the removal of an arbitrary character.

PHP

echo trim("\n\nHello World\n\n", "\n");
=> // 'Hello World'

Ruby

substitute = '\n';
puts "\n\nHello World\n\n".gsub(/^[#{substitute}]+|[#{substitute}]+$/, '')
=> # 'Hello World'

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.