php二维数组置换。。。;在英语中,单个语音有多个字母
我有一组语音,有多个交替的英文字母php二维数组置换。。。;在英语中,单个语音有多个字母,php,combinations,permutation,Php,Combinations,Permutation,我有一组语音,有多个交替的英文字母 $q[0][0]="c"; $q[1][0]="k"; $q[2][0]="q"; --- $q[0][1]="u"; $q[1][1]="a"; -- $q[0][2]="t" 我有一个包含单词的单词表 切 放 标签 我想在2d数组上面排列,生成一个包含所有可能单词的查询 cut qat kut -- cat qut kat ---- 或者,我们也可以包括并继续上述系列,以满足编程逻辑需求 tac tuc tak --- tuq taq tuk
$q[0][0]="c";
$q[1][0]="k";
$q[2][0]="q";
---
$q[0][1]="u";
$q[1][1]="a";
--
$q[0][2]="t"
我有一个包含单词的单词表 切 放 标签 我想在2d数组上面排列,生成一个包含所有可能单词的查询
cut
qat
kut
--
cat
qut
kat
----
或者,我们也可以包括并继续上述系列,以满足编程逻辑需求
tac
tuc
tak
---
tuq
taq
tuk
---
act
ukt
uct
---
我所需要的是数组变量,比如$word{$i],它具有所有上述可能的置换字。
当我在查询可能的单词上面运行时,它只会在表中找到“cut”,我会用“cut”替换“ڪَٽ”…是的,它的罗马翻译
我尝试过的编程仍然是
<input type="text" name="leng" id="leng" value="" ><input type='submit' name='submit'></form>
<?php
if(isset($_POST['submit'])){
for($i=0; $i<=3; $i++){ //3 is number of listboxes or length of given string
//echo $list[$i];
for ($x=0; $x<= $_POST['leng']; $x++){
?>
<script>
document.getElementById("leng").value = document.getElementById("<?php echo $list[$i]; ?>").length;
</script>
document.getElementById(“leng”).value=document.getElementById(“”)长度;
//我在上面制作了三个名为list0、list1、list3的列表框
线
list0=“c,q,k”
list1=“u,a”
list2=“t”
这是我尝试过的完整程序。。。。
问题是“如果有人把“法哈德”字符串写成英语,那么我就必须把它翻译成信德语,在信德语中,单个英语字母有多个替代字母,比如f有两个替代字母,a有三个替代字母,h有三个替代字母
所有备选字母都被写入数据库表中,与英文字母相对……。首先,我将每个字母搜索到字母备选表格中……如果找到,我将逐个放入列表/选择框中……所有列表框都等于“fahad”的长度数,因此生成5个列表框。。。。。
并将当前列表框的长度放入$_POST['leng']文本框。。。。。
现在我在这里做$q数组的排列
然后我计算出每5个单词的长度
global $servername;
global $username;
global $password;
global $dbname;
$servername = "localhost";
$username = "root";
$password = "";
$dbname = "tsrs";
//////////////////////
global $q;
$q=array();
//////////////////////
for ($n=0; $n<=strlen("fahad"); $n++){
$i=substr("fahad", $n, 1);
//echo $i;
/////////////////////
$conn = new mysqli($servername, $username, $password, $dbname);
// Check connection
if ($conn->connect_error) {
die("Connection failed: " . $conn->connect_error);
}
mysqli_set_charset($conn,"utf8");
$sql = "SELECT * FROM duplicate WHERE engletter='$i' order by id";
$result = $conn->query($sql);
global $m;
$m=0;
if ($result->num_rows > 0) {
$altrntcount=$result->num_rows;
while($row = $result->fetch_assoc()) {
$q[$n][$m]=$row['sinletter'] ;
echo $q[$n][$m]."<BR>";
$m=$m+1;
}
}
}
echo "<form method='post'>";
for ($n=0; $n<=strlen("fahad")-1; $n++){
$list[$n]="list".$n;
echo $list[$n];
echo "
<select name=\"".$list[$n]."\" id=\"".$list[$n]."\">";
for ($m=0; $m<=$altrntcount-1; $m++){
if ($q[$n][$m]<>""){
echo "<option value=\"".$q[$n][$m]."\">".$q[$n][$m]."</option>";
}
}
echo "</select>";
}?>
<input type="text" name="leng" id="leng" value="1" ><input type='submit' name='submit'></form>
<?php
if(isset($_POST['submit'])){
for($i=0; $i<=strlen("fahad")-1; $i++){
//echo $list[$i];
for ($x=0; $x<= $_POST['leng']+1; $x++){
?>
<script>
document.getElementById("leng").value = document.getElementById("<?php echo $list[$i]; ?>").length;
</script>
<?php
echo $i."-i: I : ".$x.": X <BR>";
echo $q[$i][$x];
}
}
echo "<h1>".($_POST['leng'])."zzz</h1>";
echo "-----<BR><BR><BR>++++++";
}
?>
<?php
global $q;
//$arrStart = array(
//array('ف', 'ڦ', 'په'),
// array('ح', 'ه'),
//array('د', 'ڊ','ڏ')
//);
//$arrStart= $q[$i][$x];
$arrPositions = array();
$arrResult = array();
//get a starting position set for each sub array
for ($i = 0; $i < count($q); $i++)
$arrPositions[] = 0;
//repeat until we've run out of items in $q[0]
while (array_key_exists($arrPositions[0], $q[0])) {
$arrTemp = array();
$blSuccess = true;
//go through each of the first array levels
for ($i = 0; $i < count($q); $i++) {
//is there a item in the position we want in the current array?
if (array_key_exists($arrPositions[$i], $q[$i])) {
//add that item to our temp array
$arrTemp[] = $q[$i][$arrPositions[$i]];
} else {
//reset this position, and raise the one to the left
$arrPositions[$i] = 0;
$arrPositions[$i - 1]++;
$blSuccess = false;
}
}
//this one failed due to there not being an item where we wanted, skip to next go
if (!$blSuccess) continue;
//successfully adding nex line, increase the right hand count for the next one
$arrPositions[count($q) - 1]++;
//add our latest temp array to the result
$arrResult[] = $arrTemp;
}
print_r($arrResult);
if(isset($_POST['submit'])){
for($i=0; $i<=count($arrResult)-1; $i++){
//echo $list[$i];
?>
<script>
document.getElementById("leng").value = document.getElementById("<?php echo $list[$i]; ?>").length;
</script>
<?php
for ($x=0; $x<= $_POST['leng']+2; $x++){
//echo $i."-i: I : ".$x.": X <BR><BR><BR>";
echo $arrResult[$i][$x];
}
echo "<BR><BR>";
}
echo "<h1>".($_POST['leng'])."zzz</h1>";
echo "-----<BR><BR><BR>++++++";
}
global$servername;
全局$用户名;
全局$密码;
全局$dbname;
$servername=“localhost”;
$username=“root”;
$password=“”;
$dbname=“tsrs”;
//////////////////////
全球$q;
$q=数组();
//////////////////////
对于($n=0;$n连接错误){
die(“连接失败:”.$conn->connect\U错误);
}
mysqli_set_charset($conn,“utf8”);
$sql=“从重复中选择*,其中engletter='$i'按id排序”;
$result=$conn->query($sql);
全球500万美元;
$m=0;
如果($result->num_rows>0){
$altrntcount=$result->num\u行;
而($row=$result->fetch_assoc()){
$q[$n][$m]=$row['sinletter'];
回音$q[$n][$m]。“
”;
$m=$m+1;
}
}
}
回声“;
对于($n=0;$n)
document.getElementById(“leng”).value=document.getElementById(“”)长度;
global $servername;
global $username;
global $password;
global $dbname;
$servername = "localhost";
$username = "root";
$password = "";
$dbname = "tsrs";
//////////////////////
global $q;
$q=array();
//////////////////////
for ($n=0; $n<=strlen("fahad"); $n++){
$i=substr("fahad", $n, 1);
//echo $i;
/////////////////////
$conn = new mysqli($servername, $username, $password, $dbname);
// Check connection
if ($conn->connect_error) {
die("Connection failed: " . $conn->connect_error);
}
mysqli_set_charset($conn,"utf8");
$sql = "SELECT * FROM duplicate WHERE engletter='$i' order by id";
$result = $conn->query($sql);
global $m;
$m=0;
if ($result->num_rows > 0) {
$altrntcount=$result->num_rows;
while($row = $result->fetch_assoc()) {
$q[$n][$m]=$row['sinletter'] ;
echo $q[$n][$m]."<BR>";
$m=$m+1;
}
}
}
echo "<form method='post'>";
for ($n=0; $n<=strlen("fahad")-1; $n++){
$list[$n]="list".$n;
echo $list[$n];
echo "
<select name=\"".$list[$n]."\" id=\"".$list[$n]."\">";
for ($m=0; $m<=$altrntcount-1; $m++){
if ($q[$n][$m]<>""){
echo "<option value=\"".$q[$n][$m]."\">".$q[$n][$m]."</option>";
}
}
echo "</select>";
}?>
<input type="text" name="leng" id="leng" value="1" ><input type='submit' name='submit'></form>
<?php
if(isset($_POST['submit'])){
for($i=0; $i<=strlen("fahad")-1; $i++){
//echo $list[$i];
for ($x=0; $x<= $_POST['leng']+1; $x++){
?>
<script>
document.getElementById("leng").value = document.getElementById("<?php echo $list[$i]; ?>").length;
</script>
<?php
echo $i."-i: I : ".$x.": X <BR>";
echo $q[$i][$x];
}
}
echo "<h1>".($_POST['leng'])."zzz</h1>";
echo "-----<BR><BR><BR>++++++";
}
?>
<?php
global $q;
//$arrStart = array(
//array('ف', 'ڦ', 'په'),
// array('ح', 'ه'),
//array('د', 'ڊ','ڏ')
//);
//$arrStart= $q[$i][$x];
$arrPositions = array();
$arrResult = array();
//get a starting position set for each sub array
for ($i = 0; $i < count($q); $i++)
$arrPositions[] = 0;
//repeat until we've run out of items in $q[0]
while (array_key_exists($arrPositions[0], $q[0])) {
$arrTemp = array();
$blSuccess = true;
//go through each of the first array levels
for ($i = 0; $i < count($q); $i++) {
//is there a item in the position we want in the current array?
if (array_key_exists($arrPositions[$i], $q[$i])) {
//add that item to our temp array
$arrTemp[] = $q[$i][$arrPositions[$i]];
} else {
//reset this position, and raise the one to the left
$arrPositions[$i] = 0;
$arrPositions[$i - 1]++;
$blSuccess = false;
}
}
//this one failed due to there not being an item where we wanted, skip to next go
if (!$blSuccess) continue;
//successfully adding nex line, increase the right hand count for the next one
$arrPositions[count($q) - 1]++;
//add our latest temp array to the result
$arrResult[] = $arrTemp;
}
print_r($arrResult);
if(isset($_POST['submit'])){
for($i=0; $i<=count($arrResult)-1; $i++){
//echo $list[$i];
?>
<script>
document.getElementById("leng").value = document.getElementById("<?php echo $list[$i]; ?>").length;
</script>
<?php
for ($x=0; $x<= $_POST['leng']+2; $x++){
//echo $i."-i: I : ".$x.": X <BR><BR><BR>";
echo $arrResult[$i][$x];
}
echo "<BR><BR>";
}
echo "<h1>".($_POST['leng'])."zzz</h1>";
echo "-----<BR><BR><BR>++++++";
}