0
$solutionsMap = [];
$score = 655536;

in js I have if(solutionsMap.indexOf(score) === -1).

I need an equivalent in php for solutionsMap.indexOf(score) === -1. I tried array_search(), strpos(), but with errors.

I searched before this question, but I still got errors.

Bogdan C
  • 403
  • 1
  • 4
  • 16

1 Answers1

0

Use the array_search() function:

$k = array_search('text', $array);

For example:

$solutionsMap = array('655536' => 'score', 1 => 'other');

$key = array_search('score', $solutionsMap); // $key = 655536;

echo $key;

Output:

655536

Try it here.

user2342558
  • 4,717
  • 5
  • 27
  • 50