I have an array like this :
array("Peter"=>"35", "Ben"=>"37", "Joe"=>"43");
and would like to get only my values, for example here :
simpleTab=array("35","37","43");
or otherwise like this, it should be better for me to get a list :
simpleList=["35";"37";"43"]
I'm creating a function because I'll need it several times so here it is :
$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
If you want the without Key You should use array_values()
and json_encode()
(It means convert to string) the array like
$arr = array("Peter"=>"35", "Ben"=>"37", "Joe"=>"43");
print_r(json_encode(array_values($arr)));
OutPut:
["35","37","43"]
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With