array_search()
및 unset()
귀하의 질문에 샘플 데이터를위한 좋은 방법을 보인다. 비교를 위해 다른 방법을 보여줄뿐입니다 (또는 유스 케이스가 여기에 게시 한 것과 약간 다른 경우).
방법 : (Demo)
$array=[750,563,605,598,593];
// if removing just one number apply the number as an array element
$number=605;
var_export(array_diff($array,[$number]));
// if you are performing this task with more than one $number, make $numbers=array() and do the same...
$numbers=[605,563]; // order doesn't matter
var_export(array_diff($array,$numbers));
// if you need to re-index the output array, use array_values()...
$numbers=[605,563]; // order doesn't matter
var_export(array_values(array_diff($array,$numbers)));
출력 : 신 위해서
array (
0 => 750,
1 => 563,
3 => 598,
4 => 593,
)
array (
0 => 750,
3 => 598,
4 => 593,
)
array (
0 => 750,
1 => 598,
2 => 593,
)
- 문서 http://ru2.php.net/manual/en/ref.array를 참조하십시오. ph – zerkms
3 가지 질문이 있습니다. [최소 및 최대 찾기] (http://stackoverflow.com/questions/1428800/getting-the-min-and-max-values-from-a-php-array) 3 번 질문을보십시오. – styfle
OK, I 최소값과 최대 값을 찾고 중복을 제거했지만 특정 값이 있으면 제거하는 방법은 무엇입니까? 나는이 질문 만 집어 넣을 것이다. – stefmikhail