Skip to content

Instantly share code, notes, and snippets.

@objectivehtml
Created September 30, 2011 17:05
Show Gist options
  • Save objectivehtml/1254367 to your computer and use it in GitHub Desktop.
Save objectivehtml/1254367 to your computer and use it in GitHub Desktop.
Simple Rtrim EE Plugin
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
$plugin_info = array(
'pi_name' => 'Rtrim',
'pi_version' => '1.0',
'pi_author' => 'Justin Kimbrell',
'pi_author_url' => 'http://objectivehtml.com/',
'pi_description' => 'Removes characters form the end of a string.',
'pi_usage' => Rtrim::usage()
);
class Rtrim
{
public function __construct()
{
$this->EE =& get_instance();
$string = $this->EE->TMPL->fetch_param('string');
$trim = $this->EE->TMPL->fetch_param('trim');
if($string === FALSE)
show_error('You must define a string parameter');
if($trim === FALSE)
show_error('You must define a trim parameter');
$this->return_data = rtrim($string, $trim);
}
public static function usage()
{
ob_start(); ?>
{exp:rtrim string="some string to trim/" trim="/"}
<?php
$buffer = ob_get_contents();
ob_end_clean();
return $buffer;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment