您能帮我制作一个时尚的文本生成器吗?

时间:2019-05-15 07:16:34

标签: php

我想制作一个文本生成器,为我提供带有鮩†ø之类的时尚字母而不是eRCTo的文本。 我发现了:

/*
Code by ʍɨȼhą€ℓ
*/

$name = str_split('michael'); //Enter your name here
$letters = array("a"=>"ą", "b"=>"β", "c"=>"ȼ", "d"=>"ď", "e"=>"€", "f"=>"ƒ", "g"=>"ǥ", "h"=>"h", "i"=>"ɨ", "j"=>"j", "k"=>"Ќ", "l"=>"ℓ", "m"=>"ʍ", "n"=>"ɲ", "o"=>"๏", "p"=>"ρ", "q"=>"ǭ", "r"=>"я", "s"=>"$", "t"=>"ţ", "u"=>"µ", "v" => "ש","w"=>"ώ", "x"=>"ж", "y"=>"¥", "z"=>"ƶ");

$string = '';

$output = array(); 

foreach ($name as $key) { 
 if (array_key_exists($key, $letters)) { 
     $output[$key] = $letters[$key]; 

 } 
}

foreach ($output as $out) 
{
   $string .= "$out";
}  
echo $string;

它与Michael伟大的名字一起工作!但是,如果我使用aaabbcdd,它将返回ąβȼď。 我也希望它返回重复的字母!我该怎么办?


感谢您的帮助。我更改了整个代码。 如果有人想要更新更好的代码,我会回答。

4 个答案:

答案 0 :(得分:0)

$name = str_split('aaabbcdd'); //Enter your name here


$letters = array("a"=>"ą", "b"=>"β", "c"=>"ȼ", "d"=>"ď", "e"=>"€", "f"=>"ƒ", "g"=>"ǥ", "h"=>"h", "i"=>"ɨ", "j"=>"j", "k"=>"Ќ", "l"=>"ℓ", "m"=>"ʍ", "n"=>"ɲ", "o"=>"๏", "p"=>"ρ", "q"=>"ǭ", "r"=>"я", "s"=>"$", "t"=>"ţ", "u"=>"µ", "v" => "ש","w"=>"ώ", "x"=>"ж", "y"=>"¥", "z"=>"ƶ");


$string = ''; 

foreach ($name as $key) { 
  if (array_key_exists($key, $letters)) {
    $string .= $letters[$key]; 
  }
}

echo $string;

我简化了一点。我删除了输出数组,并将相应的字母直接附加到输出字符串。

现在,您的脚本逐字符遍历字符串char,并将正确的替换项直接附加到输出中。

michael的输出:ʍɨȼhą€ℓ

aaabbcdd的输出:ąąąββȼďď

我认为问题在于,如果输出数组中的键相同,则您确实覆盖了值。

因此,使用$output[$key] = $letter[$key]设置密钥a,但是如果$key再次为a,则在下一次循环迭代中覆盖密钥。

使用上面的脚本不会再发生这种情况。

答案 1 :(得分:0)

修改此内容:

foreach ($name as $key) { if (array_key_exists($key, $letters)) { $output[$key] = $letters[$key]; } }

进入:

foreach ($name as $key => $value) { if (array_key_exists($value, $letters)) { $output[$key] = $letters[$value]; } }

因此,由于相同的数组键索引,结果数组不会被覆盖。

答案 2 :(得分:0)

将字符串作为数组进行循环,然后将结果直接合并为输出:

$name = 'michael'; //Enter your name here
$letters = array("a"=>"ą", "b"=>"β", "c"=>"ȼ", "d"=>"ď", "e"=>"€", "f"=>"ƒ", "g"=>"ǥ", "h"=>"h", "i"=>"ɨ", "j"=>"j", "k"=>"Ќ", "l"=>"ℓ", "m"=>"ʍ", "n"=>"ɲ", "o"=>"๏", "p"=>"ρ", "q"=>"ǭ", "r"=>"я", "s"=>"$", "t"=>"ţ", "u"=>"µ", "v" => "ש","w"=>"ώ", "x"=>"ж", "y"=>"¥", "z"=>"ƶ");

$output= '';
for($i=0;$i<strlen($name);$i++)
  if (array_key_exists($name[$i], $letters))
    $output .= $letters[$name[$i]]; 

echo $output;

答案 3 :(得分:0)

在对最后一个代码进行了一些工作之后,我决定从第一个代码开始编写……它比最后一个更好,并且可以更轻松地自定义。 您可以轻松地改进其代码,并随时使用它 我只填写我需要的字母。 $total变量将为您提供结果。

<?php

$me = "mammad"; // Put Your Text Here.

$a = array("Aͣ" , "@ͣ" , "ⓐͣ" , "Ⓐͣ" , "αͣ" , "ɐͣ" , "ͣ" , "a̶ͣ" , "aͣ͟" , "aͣ" , "ᕕͣ" , "ᐲͣ" , "ᗅͣ" , "ͣ" , "ͣ" , "丹ͣ" , "คͣ" , "ᵃ" );
$b = array("B" , "฿" , "ⓑ" , "Ⓑ" , "в" , "" , "b̶" , "b͟" , "ᗾ" , "" , "" , "乃" , "๒" , "ᵇ" );
$c = array("C" , "¢" , "℃" , "ⓒ" , "Ⓒ" , "ɔ" , "" , "c̶" , "c͟" , "cͨ" , "ᑥ" , "" , "" , "" , "匚" , "ς" , "ᶜ" );
$d = array("Dͩ" , "ⓓͩ" , "Ⓓͩ" , "∂ͩ" , "dͩ" , "ͩ" , "d̶ͩ" , "dͩ͟" , "ᴅͩ" , "dͩ" , "ᗟͩ" , "ᗥͩ" , "ͩ" , "ͩ" , "刀ͩ" , "๔ͩ" , "ᵈͩ" , "ᴰ" );
$e = array("E" , "€" , "ᴱ" , "ξ" , "Ⓔ" , "Ǝ" , "" , "E̶" , "E͟" , "ᓬ" , "" , "" , "ᴱ" , "ε" , "e" , "ⓔ" , "eͤ" , "ә" , "e̶" , "ᗴ" , "モ" , "ᵉ" );
$f = array();
$g = array();
$h = array("H" , "ⓗ" , "Ⓗ" , "" , "H̶" , "H͟" , "H_" , "" , "" , "ᴴ" , "н" , "ɥ" , "hͪ" , "h̶" , "h͟" , "hͪ" , "ђ" , "ʰ" );
$i = array();
$j = array();
$k = array();
$l = array();
$m = array("Mͫ" , "ⓜͫ" , "Ⓜͫ" , "ͫ" , "M̶ͫ" , "Mͫ͟" , "ᘻͫ" , "ͫ" , "ͫ" , "ᴹͫ" , "๓ͫ" , "ɯͫ" , "m̶ͫ" , "mͫ͟" , "ᴍͫ" , "mͫ" , "ᗰͫ" , "ᙏͫ" , "爪ͫ" , "ᵐ" );
$n = array();
$o = array();
$p = array();
$q = array();
$r = array();
$s = array();
$t = array();
$u = array();
$v = array();
$w = array();
$x = array();
$y = array();
$z = array();

$l = array("a"=> $a , "b"=> $b , "c"=> $c , "d"=> $d , "e"=> $e , "f"=> $f , "g"=> $g , "h"=> $h , "i"=> $i , "j"=> $j , "k"=> $k , "l"=> $l , "m"=> $m , "n"=> $n , "o"=> $o , "p"=> $p , "p"=> $q , "r"=> $r , "s"=> $s , "t"=> $t , "u"=> $u , "v"=> $v , "w"=> $w , "x"=> $x , "y"=> $y , "z"=> $z );

$name = str_split($me);
$string = '';
$add = count($name);

for ($a=0; $a < $add; $a++) {
    $key = $name[$a];
    $letter = $l[$key];
    $tedad = count($letter);
    $r = rand(0,$tedad);
    $string .= $letter[$r];}

$matn = $string;
$left = array(".o0×X","••.•´¯","׺°”˜","ıllıllı","▄▀▄▀","★·.·´¯");
$right = array("X×0o.","¯`•.••","˜`”°º×","ıllıllı","▀▄▀▄","¯`·.·★");
$rr = rand(0,5);
$total = "$left[$rr]~$matn~$right[$rr]";

echo $total;