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 $str = 'one,two,three,four'; print_r(explode(',', $str)); ?>
上面的代码会打印出来:
Array ( [0] => one [1] => two [2] => three )
有人知道如何访问这些密钥吗?如果我只想回显 [1] 键,我会怎么做?任何帮助都会很棒!谢谢!
将分解后的值存储在数组中...
$str = 'one,two,three,four'; $temparray=explode(',', $str); echo $temparray[1]; // two echo $temparray[0]; // one....