Jump to content
php.lv forumi

apgriezt garus vaardus


nemec

Recommended Posts

function check_input($input, $maxlenght= 32)
$temp_array = explode(" ", $input);
foreach ($temp_array as $word) {
 if (strlen($word) > $maxlenght) {
  return false;
 }
}
return true;
}

Piemērs:

if (!check_input($_POST['message'])) {
echo 'One of your words in your message in longer than 32 chars. Please edit your message.';
}

 

http://lv.php.net/manual/en/function.strlen.php#54846

Edited by AcidRain
Link to comment
Share on other sites

<?php

if ( strlen($text) > 32 ) { // $text ir vaards

for($i=0;$i<32;$i++) {

echo $text[$i]; } // paraadiit tikai pirmos 32 simbolus

}

?>

 

ja gribi vārdu ierakstīt kaukādā dokumentā, tad

 

if ( strlen($text) > 32 ) {

for ($i=0;$i<32;$i++) {

fputs(fopen("doc.txt", "w"), $text[$i]);

}

}

Edited by php_Stopp
Link to comment
Share on other sites

function stringLimit($string, $length = 50, $ellipsis = '...') {
  return strlen($fragment = substr($string, 0, $length + 1 - strlen($ellipsis))) < strlen($string) + 1 ?
      preg_replace('/\s*\S*$/', '', $fragment) . $ellipsis : $string;
}

ja mekleetu manuaalii tad atrastu. shii ir no manuaalja.

Link to comment
Share on other sites

×
×
  • Create New...