PHP Classes
elePHPant
Icontem

File: ChangeCharacters.php

Recommend this page to a friend!
Stumble It! Stumble It! Bookmark in del.icio.us Bookmark in del.icio.us
  Classes of Juan Chaves  >  Change Characters  >  ChangeCharacters.php  >  Download  
File: ChangeCharacters.php
Role: Example script
Content type: text/plain
Description: Change Chatacters
Class: Change Characters
Replace characters in a text strings
Author: By
Last change: add new comment
Date: 1 year ago
Size: 1,201 bytes
 

Contents

Class file image Download
<?php
/**
 * This is a very simple class that can be used to replace characters in a text strings.
 * @author Juan Chaves, juan.cha63@gmail.com
 * Copyright (C) 2010 Juan Chaves
 * This program is free software; distributed under the artistic license.
 */
 
class ChangeCharacters {
   
/**
     * Characters change
     * @var private array
     */
   
private $matriz;
   
/**
     * String to check
     * @var public string
     */
   
public $string_change;
   
   
/**
     * Method public go.
     * @param string $string_change String to check.
     * @return modified character string Method private change_to
     */
   
public function go( $string_change ) {
        return
$this->change_to( $string_change );
    }

   
/**
     * Method private change_to.
     * @param string $string_change String to check.
     * @return modified character string
     */
   
private function change_to( $string_change ) {
       
$matriz['á'] = 'a';//Delete or add characters to be replaced.
       
$matriz['-'] = '';
       
$matriz['_'] = '';
       
$matriz[' '] = '';
        return
strtr( $string_change, $matriz );
    }
}

//example of how to apply
$ChangeCharacters = new ChangeCharacters();
echo
$ChangeCharacters->go( 'Página_1 3' );

?>