04-array_search

<?php
$array = array(0 => 'blue', 1 => 'red', 2 => 'green', 3 => 'red');
echo $key = array_search('green', $array); // $key = 2;
echo "<br>";
echo $key = array_search('red', $array); // $key = 1;
?>


輸出2和1

PHP
01 StringCH02 ArrayCH03 檔案