View Single Post
Old 11-08-2003, 10:34 AM   #11
Charter
Head Mole
 
Charter's Avatar
 
Join Date: May 2003
Posts: 2,539
Hi. Try running the following code (remove any "word" wrapping if necessary).
PHP Code:
<?php

$text 
"My t-shirt is blue.";

define('PHPDIG_ENCODING','iso-8859-1');
$phpdig_string_subst['iso-8859-1'] = 'A:ÀÁÂÃÄÅ,a:*áâãäå,O:ÒÓÔÕÖØ,o:òóôõöø,E:ÈÉÊË,e:èéêë,C:Ç,c:ç,I:ÌÍÎÏ,i:ì*îï,U:ÙÚÛÜ,u:ùúûü,Y:Ý,y:ÿý,N:Ñ,n:ñ';
$phpdig_words_chars['iso-8859-1'] = '[:alnum:]ðþß';

$text phpdigEpureText($text);

function 
phpdigEpureText($text,$min_word_length=2,$encoding=PHPDIG_ENCODING) {
global 
$phpdig_words_chars;

echo 
$text " A<---<br><br>\n";
$text phpdigStripAccents(strtolower ($text));
echo 
$text " B<---<br><br>\n";
//no-latin upper to lowercase - now islandic
switch (PHPDIG_ENCODING) {
   case 
'iso-8859-1':
   
$text strtr$text,'ÐÞ','ðþ');
   break;
}
echo 
$text " C<---<br><br>\n";
$text ereg_replace('[[:blank:]][0-9]+[[:blank:]]',' ',ereg_replace('[^'.$phpdig_words_chars[$encoding].'._&%/-]+',' ',$text));
echo 
$text " D<---<br><br>\n";
$text ereg_replace('[[:blank:]][^ ]{1,'.$min_word_length.'}[[:blank:]]',' ',' '.$text.' ');
echo 
$text " E<---<br><br>\n";
$text ereg_replace('\\.+[[:blank:]]|\\.+$|\\.{2,}',' ',$text);
echo 
$text " F<---<br><br>\n";
return 
trim(ereg_replace("[[:blank:]]+"," ",$text));
}

function 
phpdigStripAccents($chaine,$encoding=PHPDIG_ENCODING) {
$phpdigEncode = array();
global 
$phpdigEncode;
if (!isset(
$phpdigEncode[$encoding])) {
   
$encoding PHPDIG_ENCODING;
}
// exceptions
if ($encoding == 'iso-8859-1') {
    
$chaine str_replace('Æ','ae',str_replace('æ','ae',$chaine));
}
return( 
strtr$chaine,$phpdigEncode[$encoding]['str'],$phpdigEncode[$encoding]['tr']) );
}

echo 
$text " G<---<br><br>\n";

?>
What is the output when viewing the HTML source? The output I get is the following.
Code:
My t-shirt is blue. A<---<br><br>
my t-shirt is blue. B<---<br><br>
my t-shirt is blue. C<---<br><br>
my t-shirt is blue. D<---<br><br>
 t-shirt blue.  E<---<br><br>
 t-shirt blue  F<---<br><br>
t-shirt blue G<---<br><br>
__________________
Responses are offered on a voluntary if/as time is available basis, no guarantees. Double posting or bumping threads will not get your question answered any faster. No support via PM or email, responses not guaranteed. Thank you for your comprehension.
Charter is offline   Reply With Quote