Problemi con Zend Framework o php? Contattaci!
Riportiamo di seguito un utile filtro scritto in PHP e predisposto all’uso con Zend Framework per filtrare una stringa e renderla grammaticalmente corretta alle regole che afferiscono ai nomi propri di persona nella grammatica Italiana.
/**
* Zend Framework
*
* LICENSE
*
* This source file is subject to the new BSD license that is bundled
* with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://framework.zend.com/license/new-bsd
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to license@zend.com so we can send you a copy immediately.
*
* @category Zend
* @package Zend_Filter
* @copyright Draco Corporation (http://www.draco-corporation.com)
* @license Draco Corporation (http://www.draco-corporation.com)
* @version PersonName.php 1 2013-04-25 11:17
* @author Draco Corporation (http://www.draco-corporation.com)
*/
/**
* @see Zend_Filter_Interface
*/
require_once 'Zend/Filter/Interface.php';
/**
* @see Zend_Locale
*/
require_once 'Zend/Locale.php';
/**
* @category Zend
* @package Zend_Filter
* @copyright Draco Corporation (http://www.draco-corporation.com)
* @license Draco Corporation (http://www.draco-corporation.com)
*/
class Zend_Filter_PersonName implements Zend_Filter_Interface
{
/**
* Defined by Zend_Filter_Interface
*
* returns the name of the person with the first letter capitalized
*
* @param string $value
* @return string
*/
public function filter($value)
{
//reduces all characters enlarging only the first character of each word
$value = ucwords(strtolower($value));
//If the name is an accent is enlarged after the first letter of this
$value = preg_replace('/'(w+)/e', "'''.ucfirst('$1')", $value);
return $value;
}
}
Hai bisogno di una consulenza o assistenza?
Apri un ticket di richiesta, ti risponderò in brevissimo tempo! Chiedere non costa nulla 😉