<?php
 
/**
 
 * This is a very simple class that can be used to replace characters in a text strings.
 
 * @author Juan Chaves, [email protected]
 
 * 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' );
 
 
?> 
 
 |