I m 使用字母。 js to Packcode><span> elements around each letter in a string. I m 正在使用PHP进行铺设。 在下面的例子中,$bellcurve
尚未界定,例如,我想象的办法可能会使我获得解决办法,但事实上,我不敢肯定这是否正确(但问题在于此)。
因此:
$string = "Hey!! Don t be an apple!"
我想计算一下该插图中的特性,然后,就每个特性而言,形成如下的等级声明,每个数值都是“顶”的,造成整体的伤亡。
我的购买力平价知识使我知道:
$string = "Hey!! Don t be an apple!";
$string = str_split($string);
$i = 1;
foreach($string as $char){
echo .char . $i . {top: . $bellcurve * $i . px} ;
$i++;
}
例如,在这项工作中进行的快速尝试是人工地看着:
span.char1 {top: 20px}
span.char2 {top: 18px}
span.char3 {top: 16px}
span.char4 {top: 15px}
span.char5 {top: 14px}
span.char6 {top: 13px}
span.char7 {top: 12px}
span.char8 {top: 11px}
span.char9 {top: 10px}
span.char10 {top: 10px}
span.char11 {top: 10px}
span.char12 {top: 9px}
span.char13 {top: 9px}
span.char14 {top: 10px}
span.char15 {top: 10px}
span.char16 {top: 10px}
span.char17 {top: 11px}
span.char18 {top: 12px}
span.char19 {top: 13px}
span.char20 {top: 14px}
span.char21 {top: 15px}
span.char22 {top: 16px}
span.char23 {top: 18px}
span.char24 {top: 20px}
What I need to know how to do is create a coefficient ( $bellcurve
) which, when multiplied by $i (the character index), will create a bell curve when iterated over the total number of characters.
或者如果有一个更好的办法,请让我知道!
感谢!
这里的答案是从javascript改为PHP的:
<?php
$string = get( character_slogan );
$string = str_split($string);
$count = count($string);
$pi = pi();
$c = 1.0;
$b = $count / 2;
$piece = sqrt(2*$pi);
$a = 1 / ($c*$piece);
?>
<style type="text/css">
<?php
$x = 1;
foreach($string as $char){
$E = M_E;
$bellcurve = ($a*$E)-(pow($x-$b, 2)/pow(2*$c, 2));
echo .char . $x . {top: . -$bellcurve . px}
;
$x++;
}
?>
</style>