<?php
function validate( $string )
{
$block[] = array( 1, 2, 3, 4, 5, 6, 7, 8, 9, 0 ); $block[] = array( 'um', 'dois', 'tres', 'quatro', 'cinco', 'seis', 'sete', 'oito', 'nove', 'zero' ); $string = explode( ' ' , $string );
//
foreach( $string as $i => $palavra )
{
if( isset( $string[$i-1] ) ) $match[] = $string[$i-1];
$match[] = $string[$i];
if( isset( $string[$i+1] ) ) $match[] = $string[$i+1];
if( count( $possivel ) === 3 ) $sequencia[] = $possivel;
}
return $sequencia;
}
// texto com informações
$sequencia = validate( "meu 1 dois 3 telefone ligue quatro cinco zero" );
if( count( $sequencia ) > 0 ) {
echo 'possível sequência: ';
}
else
{
echo 'parece ok.';
}
// texto limpo
$sequencia = validate( "Lorem Ipsum is simply dummy text of the printing and typesetting industry." );
if( count( $sequencia ) > 0 ) {
echo 'possível sequência: ';
}
else
{
echo 'parece ok.';
}
PD9waHAKCmZ1bmN0aW9uIHZhbGlkYXRlKCAkc3RyaW5nICkKewoJJGJsb2NrW10gICA9IGFycmF5KCAxLCAyLCAzLCA0LCA1LCA2LCA3LCA4LCA5LCAwICk7CgkkYmxvY2tbXSAgID0gYXJyYXkoICd1bScsICdkb2lzJywgJ3RyZXMnLCAncXVhdHJvJywgJ2NpbmNvJywgJ3NlaXMnLCAnc2V0ZScsICdvaXRvJywgJ25vdmUnLCAnemVybycgKTsKCSRibG9jayAgICAgPSBhcnJheV9tZXJnZSggJGJsb2NrWzBdICwgJGJsb2NrWzFdICk7Cgkkc2VxdWVuY2lhID0gYXJyYXkoKTsKCSRzdHJpbmcgICAgPSBleHBsb2RlKCAnICcgLCAkc3RyaW5nICk7CgoKCS8vCglmb3JlYWNoKCAkc3RyaW5nIGFzICRpID0+ICRwYWxhdnJhICkKCXsKCQkkbWF0Y2ggPSBhcnJheSgpOwoJCgkJaWYoIGlzc2V0KCAkc3RyaW5nWyRpLTFdICkgKQoJCSRtYXRjaFtdID0gJHN0cmluZ1skaS0xXTsKCQoJCSRtYXRjaFtdID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