Getting values to compare from a Explode Array of Strings

I have this string that I'm Getting from a Mysql Result:

Result1:

1/test3&2/test4&

Then, I have some ID from another mysql Result like this:

Result2:

$id = $row['id'];

Then I'm using an Explode in order to separate Result1:. Like I'm Getting this:

$nota3 = explode("&", $nota);

1/test3&
2/test4&

Now, I'm doing I'm using a foreach and then using another explode to separate the string by "/" delimiter.

foreach ($nota3 as $key) {

$nota4 = explode("/", $key);

}

The Result of this its something like this (for the firsts foreach iteration):

array(2) {
  [0]=>
  string(1) "1"
  [1]=>
  string(5) "test3"
}

Ok, So I cannot Compare nota4[0] with $id from Result2:

Things that I've Tried:

  • Using if and verify every type, converts nota4[0] a $id to string

  • Try to use in_Array

  • Try to use strcmp($var1, $var2)

I'm Missing something but I really dont know what.

Also, when I tried I cant put nota4[0] into a html String like

$nota5= nota4[0];

echo "<p id='mic' class='text-dark bg-warning'>".$nota5."</p>";

Maybe its something silly but I tried everything without success.



Read more here: https://stackoverflow.com/questions/67928887/getting-values-to-compare-from-a-explode-array-of-strings

Content Attribution

This content was originally published by JuanFernandoz at Recent Questions - Stack Overflow, and is syndicated here via their RSS feed. You can read the original post over there.

%d bloggers like this: