2016-09-13 5 views
1

私はこのプロジェクトに終わったので、私の意見のために、私のスキルよりもいくつかのレベルですので、私はあなたを助けてください。PHPは特定の特殊文字とPHPアルゴリズムのアイデアを削除

このプロジェクトの機能は、結合する必要のある4つの列にいくつかの単語を書き込むことです。同じ列にある単語は組み合わせてはいけません。残りの列とのみ単語を組み合わせることができます。

私はあなたに私が行ったことを見ることができるように完全なコードを与えます。

私が持っている2番目の質問は、あなたが(この場合には、「\ n」)を特殊な文字を削除する方法です


          
  
<?php 
 
    if(isset($_POST['submit'])) 
 
    { \t 
 
    \t if(isset($_POST["separator"])){$separator= $_POST["separator"];} 
 
    \t if(isset($_POST["match"])){$matchType = $_POST["match"];$matchArr = array(); 
 
    \t foreach($matchType as $match) 
 
    \t { 
 
    \t \t $matchArr = $match; 
 
    \t }} 
 
    \t $j=0; 
 
    \t $columnCount=array(); 
 
    \t $wordArr[] = array(); 
 
    \t $wordArrRows[] = array(); 
 
    \t $protasi=""; 
 
    \t $wordsCombinations = 1; 
 
    \t $wordsCounter = 0; 
 
    \t for($i=0; $i<4; $i++) 
 
    \t { \t $words=0; 
 
    \t \t $enterChar=0; 
 
    \t \t if(isset($_POST["in$i"]) && !empty($_POST["in$i"])) 
 
    \t \t { 
 
    \t \t \t $input=$_POST["in$i"]; 
 
    \t \t \t $enterChar = substr_count($input,"\n"); 
 
    \t \t \t $words= $enterChar+1; 
 
    \t \t \t if($words>0) 
 
    \t \t \t { 
 
    \t \t \t \t $wordArr[$j]= explode("\n",$input); 
 
    \t \t \t \t $wordArrRows[$j]= $words; 
 
    \t \t \t \t $j++; \t 
 
    \t \t \t } 
 
    \t \t \t $wordsCombinations*=$words; \t 
 
    \t \t } \t \t 
 
    \t } 
 
    \t 
 
    \t $i2=0; 
 
    \t $columnCounter = array_fill(0, $j, "0"); 
 
    \t while($wordsCounter < $wordsCombinations) 
 
    \t { 
 
    \t \t if($i2<sizeof($columnCounter) && $columnCounter[$i2] < $wordArrRows[$i2]) 
 
    \t \t { 
 
    \t \t \t echo "grammi: ".$i2." <br>"; 
 
    \t \t \t $i=0; 
 
    \t \t \t for($i=0; $i<$j; $i++) \t 
 
    \t \t \t { \t \t \t \t 
 
    \t \t \t \t //echo "wordArr[".$i."][".$columnCounter[$i]."]".$separator; 
 
    \t \t \t \t echo $wordArr[$i][$columnCounter[$i]]." "; \t  
 
    \t \t \t } 
 
    \t \t \t $columnCounter[$i2]++; 
 
    \t \t \t if($columnCounter[$i2] >= $wordArrRows[$i2]){$columnCounter[$i2]=0;} 
 
    \t \t \t echo "<br>"; \t \t 
 
    \t \t } 
 
    \t \t $i2++; 
 
    \t \t if($i2>=sizeof($columnCounter)){$i2=0;} \t \t \t 
 
    \t \t $wordsCounter++; 
 
    \t } 
 
    \t 
 

 
    \t 
 
    } 
 
    ?>

(注:ラジオボタンやチェックボックスを使用していない、彼ら機能していません)。

enter image description here

+1

問題の概要を示す最小限の例を提供するよう努力する必要があります。 – apokryfos

+0

私はX行の配列を持ち、すべての行は異なる列番号/サイズを持っています。私はすべての単語を残りの行の他の列の単語に結合したいが、同じ行の単語は結合しない。 このコードでは、すべての単語を含む行列を作成していますが、それらを完全に結合しようとしています。しかし、間違いがあり、完全に結合していません。 – Tinakicious

+0

私は何を意味するのかを示す画像を追加しました。 – Tinakicious

答えて

0

EDIT はその例えば予想される結果とは何ですか? 2番目の質問: "\ n"を削除するtrim()