Its JSON, to convert to array use json_decode():
$string = '{"status":"2","holding":"","company":"Company","nik":"8981237","name":"Markonah","ownercard":"Istri"}';
$my_array = json_decode($string,true);
echo $my_array["status"]; // output: 2
Answer from aidinMC on Stack Overflowphp - Parse the returned data from var_dump() - Stack Overflow
Convert array string into an array - PHP - SitePoint Forums | Web Development & Design Community
Convert particular String to Array in PHP - Stack Overflow
php - Split a string containing words into an array of individual words - Stack Overflow
Use php's "eval" function.
eval("\$myarray = $str;");
i don't know a good way to do this (only evil eval() wich realy should be avoided).
but: where do you get that string from? is it something you can affect? if so, using serialize() / unserialize() would be a much better way.
I think you might want to look into serialize and unserialize.
$myArray = array('key1'=>'value1', 'key2'=>'value2');
$serialized = serialize($myArray);
$myNewArray = unserialize($serialized);
print_r($myNewArray); // Array ( [key1] => value1 [key2] => value2 )
serialize might be the right answer - but I prefer using JSON - human editing of the data will be possible that way...
$myArray = array('key1'=>'value1', 'key2'=>'value2');
$serialized = json_encode($myArray);
$myNewArray = json_decode($serialized, true);
print_r($myNewArray); // Array ( [key1] => value1 [key2] => value2 )
As I noted in the comment to you, your example string is invalid. This example shows a valid string version of json. Use json_decode, with the 2nd parameter set to true to turn the embedded objects into array elements.
You will get an embedded array of arrays, but you can easily flatten that using the spread operator (...) with array_merge.
<?php
$string = '[{"006":"BASIC"},{"007":"ADV"}]';
$r = json_decode($string, true);
$r = array_merge(...$r);
print_r($r);
Outputs:
Array
(
[006] => BASIC
[007] => ADV
)
$string = '[{"006":"BASIC"}, {"007":"ADV"}, {"008":"ADV"}, {"009":"SUPER"}]';
var_dump(json_decode($string, true));
die;
Of if you need to join 2 arrays then you can first decode them and then merge them.
$stringOne = '[{"006":"BASIC"}, {"007":"ADV"}]';
$stringTwo = '[{"008":"ADV"}, {"009":"SUPER"}]';
$finalArray = array_merge(json_decode($stringOne, true), json_decode($stringTwo, true));
var_dump(json_encode($finalArray));
die;