【发布时间】:2017-01-07 00:11:07
【问题描述】:
我有一个用于客户端的小脚本,旨在为输入名称创建命理结果。在对名称及其对应值进行第一次迭代后,我需要在最终结果中添加数字,并获得所谓的“主编号”。我遇到的问题是迭代最终结果,它一直返回 0 - 沿着迭代检查表明它没有在数组中找到值。我哪里出错了?
<?php
if($_POST)
{
// create an array based on chaldean numerology
$ar = array('A' => 1,
'B' => 2,'C' => 3,'D' => 4,'E' => 5,'F' => 6,'G' => 7,'H' => 8,'I' => 9,
'J' => 1,'K' => 2,'L' => 3,'M' => 4,'N' => 5,'O' => 6,'P' => 7,'Q' => 8,
'R' => 9,'S' => 1,'T' => 2,'U' => 3,'V' => 4,'W' => 5,'X' => 6,'Y' => 7,
'Z' => 8,'1' => 1,'2' => 2,'3' => 3,'4' => 4,'5' => 5,'6' => 6,'7' => 7,
'8' => 8,'9' => 9);
//get the value entered by post method
$fname = $_POST['fname'];
//make it upper case. to avoid messing with small letters.
$fname = strtoupper($fname);
//find the length of the string entered
$len = strlen($fname);
//set a temp value to calculate
$fullnum = 0;
$masternum = 0;
//now loop through the string one by one and add the values
for($i=0; $i<$len; $i++)
{
$alpha = $fname[$i];
$fullnum = $ar[$alpha] + $fullnum;
}
//now loop through the fullnum one by one and add the values
$flen = strlen($fullnum);
for($i=0; $i<$flen; $i++)
{
$alpha = $fullnum[$i];
$masternum = $ar[$alpha] + $masternum;
}
//print the result
//echo "FLEN = " . $flen . "<br>";
echo "<hr>INTEGRATED SELF NUMBER: ". $fullnum . "/" . $masternum;
}
?>
<form action="" method="post">
<input type="text" name="fname" value="Full Name" />
<input type="submit" value="calculate" />
</form>
【问题讨论】:
-
这太可怕了......我几天前对这个问题发表了一些评论。现在我回来了,我看到评论消失了。我没有收到任何关于评论被删除或任何事情的通知。发生了什么?那条评论在哪里?
-
这个问题实际上有 6 个来自三个用户的问题。显然他们全部都被删除了。这在我的胃里留下了一种非常不好的感觉。这种形式的审查不应该在这里引入 SO。 尤其是不留痕迹。
-
我实际上只看到过一条评论——这令人不安……
-
我原来的评论有两条回复,确实是在开玩笑。