CopyPastor

Detecting plagiarism made easy.

Score: 1.6566836833953857; Reported for: String similarity, Exact paragraph match Open both answers

Possible Plagiarism

Plagiarized on 2018-01-26
by Léo R.

Original Post

Original - Posted on 2010-07-23
by Sarfraz



            
Present in both answers; Present only in the new answer; Present only in the old answer;

array_search is the way to do it.
From the docs:
$array = array(0 => 'blue', 1 => 'red', 2 => 'green', 3 => 'red'); $key = array_search('green', $array); // $key = 2; $key = array_search('red', $array); // $key = 1;
You could loop over the array manually and find the index but why do it when there's a function for that. This function always returns a key and it will work well with associative and normal array
Source : https://stackoverflow.com/questions/2959222/get-the-index-value-of-an-array-in-php
Use the [`array_search`][1] function.
**Example from php.net**
$array = array(0 => 'blue', 1 => 'red', 2 => 'green', 3 => 'red'); $key = array_search('green', $array); // $key = 2; $key = array_search('red', $array); // $key = 1;

[1]: http://php.net/manual/en/function.array-search.php

        
Present in both answers; Present only in the new answer; Present only in the old answer;