@@ 185-197 (lines=13) @@ | ||
182 | * @param int $fromIndex |
|
183 | * @return int|string |
|
184 | */ |
|
185 | public function indexOf($searchElement, $fromIndex = 0) |
|
186 | { |
|
187 | $result = array_search($searchElement, $this->getArrayCopy(), true); |
|
188 | ||
189 | return $result === false ? -1 : $result + $fromIndex; |
|
190 | ||
191 | // if ($fromIndex < 0) { |
|
192 | // $fromIndex = $this->length() + $fromIndex; |
|
193 | // } |
|
194 | // $result = array_search($searchElement, $this->slice($fromIndex)->getArrayCopy(), true); |
|
195 | ||
196 | // return $result === false ? -1 : $result + $fromIndex; |
|
197 | } |
|
198 | ||
199 | /** |
|
200 | * The join() method joins all elements of an array into a string. |
|
@@ 227-235 (lines=9) @@ | ||
224 | * @param int $fromIndex |
|
225 | * @return int|string |
|
226 | */ |
|
227 | public function lastIndexOf($searchElement, $fromIndex = 0) |
|
228 | { |
|
229 | $result = array_search($searchElement, array_reverse($this->getArrayCopy(), true)); |
|
230 | ||
231 | return $result === false ? -1 : $result; |
|
232 | // $result = array_search($searchElement, array_reverse($this->slice($fromIndex)->getArrayCopy(), true)); |
|
233 | ||
234 | // return ($result === false) ? -1 : $result + $fromIndex; |
|
235 | } |
|
236 | ||
237 | /** |
|
238 | * The map() method creates a new array with the results of calling a provided function on every element in this array. |