Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>change</p> <pre><code>array_push($com_study, $study_array[study]); </code></pre> <p>to</p> <pre><code>array_push($com_study, $study_array[$study]); // You missed a $ ^ here </code></pre> <p><strong>Edit:</strong><br> The following code outputs 3 'match found'. i don't know the values of <code>$common_words_array</code> and <code>$matching</code>, so i used some arbitrary values, also instead of using function <code>create_study_string_array</code> i just used explode. still confused, can't figure out what exactly you are trying to achieve.</p> <pre><code>&lt;?php $testarray = array (); $string = "this is a string"; $testarray = explode ( ' ', $string ); $common_words_array = array ( 'is', 'a', 'this' ); $matching = array ( 'a', 'and', 'this' ); $testarray = create_question ( $testarray, $matching, $common_words_array ); function create_question($study_array, $com_study, $common_words_array) { echo count ( $study_array ) . " total in study_array&lt;br&gt;"; echo count ( $common_words_array ) . " total in common_words_array&lt;br&gt;"; for($study = 0; $study &lt; count ( $study_array ); $study ++) { // echo "study is " . $study . "&lt;br&gt;"; for($common = 0; $common &lt; count ( $common_words_array ); $common ++) { // The issue happens right here. if (strcmp ( $study_array [$study], $common_words_array [$common] ) == 0) { echo "match found"; } } } $create_question_return_array = array (); $create_question_return_array [0] = $study_array; $create_question_return_array [1] = $com_study; return $create_question_return_array; } ?&gt; </code></pre> <p><em>Output:</em> </p> <pre><code>4 total in study_array 3 total in common_words_array match foundmatch foundmatch found </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload