How to convert string to character in PHP

How to convert a password string to a specified character, for example *or something else.

I am currently working on a password change page. I would like to display the password on the page, and I want someone not to pass the password, so I want to hide the password string until the character type *with the same length. An example, for example <input type="password" />.

Sorry for my bad english ...

+3
source share
6 answers
$output_password = str_repeat ('*', strlen ($input_password));
+10
source

If you are looking for an easy way to simply create an asterisk string equal to the password length:

$modified = str_repeat( "*", strlen( "secretpass" ) );

echo $modified; // **********
+1
source

HTML, (*). str_repeat:

<?php
$password = "MyPasswordThatIWantToMask";
$maskedPassword = str_repeat("*", strlen($password));
?>

$maskedPassword .

, : ? , , .

+1

:

$passwordstring = "password";
$outputpassword = "";
while(strlen($outputpassword)<strlen($passwordstring))
{
    $outputpassword .= "*";
}

echo $outputpassword
0

- , .

<input type='password' disabled='disabled' value='somepassword' />

0

, str_repeat(), , , . , , , , , <input type="password" /> (, , ? ?).

, :

<?php

  $thePassword = "thisIsMyPassword";

?>

<input type="text" id="input_user_types_in" value="<?php echo str_repeat('*', strlen($thePassword)); ?>" />
<input type="hidden" id="value_to_post_back" name="value_to_post_back" value="<?php echo $thePassword; ?>" />

<script type="text/javascript">

  var textInput = document.getElementById('input_user_types_in');
  var hiddenInput = document.getElementById('value_to_post_back');

  textInput.onfocus = function() {
    this.value = hiddenInput.value;
  };

  textInput.onblur = function() {
    var i;
    hiddenInput.value = this.value;
    this.value = '';
    for (i = 0; i < hiddenInput.value.length; i++) {
      this.value = this.value + '*';
    }
  };

</script>

fiddle, -)

0

All Articles