Created
September 30, 2011 17:52
-
-
Save objectivehtml/1254482 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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(); | |
$remove = $this->EE->TMPL->fetch_param('remove'); | |
$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'); | |
if($remove) | |
{ | |
$remove = explode('|', $remove); | |
foreach($remove as $remove_string) | |
{ | |
$string = trim($string, $remove_string); | |
} | |
} | |
$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