我有一个这样的数组: array("Peter"=>"35", "Ben"=>"37", "Joe"=>"43");
并且只想获取我的值,例如这里:
simpleTab= array("35","37","43");
或者像这样,我最好得到一个列表:
simpleList=["35";"37";"43"]
我正在创建一个函数,因为我会多次需要它,所以它是:
$simpleArray=array(); //don't know if this should be array, i'd like to have a list
foreach($valueAssoc as $key => $value{//array_push($simpleArray,$value);//NO it returns an array with keys 0 , 1 , etc
//$simpleArray[]=$value; //same ! I don't want any keys
//I want only an array without any index or key "tableau indexé sans clef"
echo $value;
//would like to have some method like this :
$simpleArray.add($value);//to add value in my list -> can't find the php method
原文由 user9417455 发布,翻译遵循 CC BY-SA 4.0 许可协议
如果你想要没有密钥你应该使用
array_values()
和json_encode()
(这意味着转换为字符串)数组输出: