Cenzurare o parte dintr-un cuvant
Scris: Lun Noi 30, 2015
Salut, cum pot cenzura o parte dintr-un cuvant ? EX: marplo , sa se transforme in m***lo
Cursuri online, tutoriale, jocuri si anime - gratuite
https://marplo.net/forum/
Cod: Selectaţi tot
// Replace in $str the characters starting from $first (0 first character) to $last, with $rep
function repStr($str, $first=0, $last=0, $rep='*'){
$begin = substr($str,0,$first);
$middle = str_repeat($rep,strlen(substr($str,$first,$last)));
$end = substr($str,$last);
$stars = $begin.$middle.$end;
return $stars;
}
$str ='marplo';
//replace in $str the characters from index 1 till the last two characters
$str2 = repStr($str, 1, -2);
echo $str2; // m***lo
Cod: Selectaţi tot
<td><?php echo $row['id']; ?></td>
<td><?php echo $row['nume']; ?></td>
<td><?php echo $row['pass']; ?></td>
Cod: Selectaţi tot
<td><?php echo $row['id']; ?></td>
<td><?php echo $row['nume']; ?></td>
<td>
<?php
function repStr($str, $first=0, $last=0, $rep='//'){
$begin = substr($str,0,$first);
$middle = str_repeat($rep,strlen(substr($str,$first,$last)));
$end = substr($str,$last);
$stars = $begin.$middle.$end;
return $stars;
}
$str = $row['pass'];
//replace in $str the characters from index 1 till the last two characters
$str2 = repStr($str, 1, -2);
echo $str2;
?>
</td>
Cod: Selectaţi tot
<td><?php echo repStr($row['pass'], 1, -2); ?></td>