我有一个数组$ old_que_ans_session
set AppleScript's text item delimiters to ""
set tmpfile to ((path to temporary items folder as string) & "Pashua_" & (characters 3 thru end of ((random number) as string)) as string)
set fhandle to open for access tmpfile with write permission
write (config as string) to fhandle as «class utf8»
close access fhandle
set posixtmpfile to POSIX path of tmpfile
我需要根据其值取消设置数组中的元素。为此,我正在执行以下操作以获取密钥
Array
(
[1] => Array
(
[home] => https://s3.ap-south-1.amazonaws.com/bmimagedump/uploads/interior/design/1533365337.jpg
)
[3] => Array
(
[home] => https://s3.ap-south-1.amazonaws.com/bmimagedump/uploads/interior/design/1531557283.jpg
)
[4] => Array
(
[home] => https://s3.ap-south-1.amazonaws.com/bmimagedump/uploads/interior/design/1531557681.jpg
)
)
如何解决这个问题。
答案 0 :(得分:1)
使用array_keys()
获取密钥列表,并使用您的$key1
值选择相关密钥...
$actualKey = array_keys($old_que_ans_session)[$key1];
在unset()
数组中的元素之前,您必须先执行此操作,否则键将消失。