Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我有一个数字索引的字符串数组。另一个数组包含第一个数组的一组索引。如果第一个数组元素的索引在第二个数组中,我想删除第一个数组中的所有元素。我怎样才能在php中做到这一点?它有什么功能吗?
$strings = array('foo', 'bar', 'baz'); $indexes = array(1, 2); $strings = array_diff_key($strings, array_flip($indexes));