Php strlen()转换为字符串

时间:2015-09-05 03:22:36

标签: php

如何使用strlen()根据字符串长度返回X星(*)?

<?PHP
  $account_name = "account1"; // 8 characters
  $account_name_length = strlen($account_name);

  // This is what i want to achieve - convert `$account_name` string length into stars.
  $account_name_hidden = "********"; // return 8 stars as string
?>

2 个答案:

答案 0 :(得分:0)

嗯,不知道你为什么要这样做,但你不能这样做吗?

<?php
$account_name = "account1" // 8 characters
$account_name_length = strlen($account_name);
$account_hidden = str_repeat('*', $account_name_length);
?>

答案 1 :(得分:0)

以这种方式:

.subul_main li.level1 { background: #ff8400; }