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
)
Answer from gview on Stack Overflow
๐ŸŒ
Simplilearn
simplilearn.com โ€บ home โ€บ resources โ€บ software development โ€บ converting string to array in php using different methods
Converting String to Array in PHP Using Different Methods
September 17, 2025 - Understand the need to convert string to array in PHP and explore the complete list of methods used to convert a string to an array in PHP. Start learning now!
Address ย  5851 Legacy Circle, 6th Floor, Plano, TX 75024 United States
Discussions

php - Split a string containing words into an array of individual words - Stack Overflow
The str_split($str, 3); splits the string in 3 character word but I need to convert the string after whitespace in an array. More on stackoverflow.com
๐ŸŒ stackoverflow.com
Array to String Conversion Error
Don't use $email on lines 20-21 for the matches returned by preg_match() if you're also going to use $email to hold the email address. If preg_match() returns a match, $email will be a string (the email address), but if it doesn't return a match, $email will be an empty array. Reuse $matches instead. May also want to double-check that the variables for name, email address etc are being cleared out as you iterate through the while loop. More on reddit.com
๐ŸŒ r/PHPhelp
2
2
March 12, 2018
Warning: Array to string conversion in Variable method
What if you try $router->{$value['method']}( $value['path'], 'something' ); This is also how you should use array items within double quoted strings, think of it as how you use parenthesis in a math formula, to specify what parts go together. With your original code, PHP can't determine if $router->$value is an array and you are trying to access the 'method' element from that (what it seems to be assuming) versus that you are trying to use the 'method' element of value. wrapping it with the curly braces, ensures it knows you mean the later. Edit: fixed typos More on reddit.com
๐ŸŒ r/PHPhelp
6
2
May 10, 2024
Array to string conversion error when running seeder
When you call DB::table()->insert() directly, it isn't using the model at all. That's why the cast has no effect. You can use Appointment::create() or manually json_encode() the arrays instead. More on reddit.com
๐ŸŒ r/laravel
1
1
September 27, 2019
People also ask

Q1. How to convert a string to array in PHP?
To convert a string to array in PHP using functions like explode(), str_split(), or preg_split(), based on how you want to split it.
๐ŸŒ
intellipaat.com
intellipaat.com โ€บ home โ€บ blog โ€บ converting a string to an array in php
Convert String to Array in PHP using Different Functions
Q5. How to convert string to array in PHP?
You can use explode(), str_split(), or preg_split() depending on whether youโ€™re splitting by delimiter, characters, or patterns.
๐ŸŒ
intellipaat.com
intellipaat.com โ€บ home โ€บ blog โ€บ converting a string to an array in php
Convert String to Array in PHP using Different Functions
Q2. How do you break a string into an array in PHP?
By using PHP explode() for delimiters or str_split() to split by characters, you can break a string to array in PHP.
๐ŸŒ
intellipaat.com
intellipaat.com โ€บ home โ€บ blog โ€บ converting a string to an array in php
Convert String to Array in PHP using Different Functions
๐ŸŒ
ReqBin
reqbin.com โ€บ code โ€บ php โ€บ p9vjxf4s โ€บ php-array-to-string-example
How do I convert an array to a string in PHP?
The serialize() function takes an array and converts it to a string. This function is handy if you want to store something in the database and retrieve it for later use. In this Convert PHP Array to String example, we use the implode() function ...
๐ŸŒ
W3Schools
w3schools.com โ€บ pHp โ€บ func_string_explode.asp
PHP explode() Function
The explode() function breaks a string into an array. Note: This function is binary-safe. ... <?php $str = 'one,two,three,four'; // zero limit print_r(explode(',',$str,0)); // positive limit print_r(explode(',',$str,2)); // negative limit ...
๐ŸŒ
Upgrad
upgrad.com โ€บ home โ€บ blog โ€บ software development โ€บ string to array in php: a list of popular functions for 2025
String to Array in PHP: What Functions You Need to Know?
June 12, 2025 - One alternative way to convert a string into an array in PHP is by manually looping through the string. This method gives you full control over how each character in the string is handled.
Find elsewhere
๐ŸŒ
GeeksforGeeks
geeksforgeeks.org โ€บ php โ€บ convert-a-string-into-an-array-of-characters-in-php
Convert a String into an Array of Characters in PHP - GeeksforGeeks
July 23, 2025 - The str_split() function is used to convert the given string into an array. This function basically splits the given string into smaller strings of length specified by the user and stores them in an array and returns the array.
๐ŸŒ
Edureka
edureka.co โ€บ blog โ€บ string-to-array-in-php
How to Convert a String to Array in PHP - Edureka
October 30, 2019 - PHP provides functions that convert from strings to arrays.
๐ŸŒ
freeCodeCamp
freecodecamp.org โ€บ news โ€บ php-explode-how-to-split-a-string-into-an-array
PHP Explode โ€“ How to Split a String into an Array
October 17, 2022 - $str = "CSS, HTML, PHP, Java, ... index is not more than the limit of 2 specified. The explode() function looks at spaces in the string to split the string into an array....
๐ŸŒ
ReqBin
reqbin.com โ€บ code โ€บ php โ€บ bnk8kgym โ€บ php-split-string-example
How do I split a string in PHP?
To split a string into an array in PHP, you can use the explode($separator, $string, $limit) function. The explode() is a built-in function that splits strings into arrays. The function takes three parameters: an input string to split, a delimiter, ...
๐ŸŒ
Drpankajdadhich
drpankajdadhich.com โ€บ home โ€บ subjects โ€บ manipulating the string as an array in php
Manipulating the string as an array in PHP
May 29, 2022 - Following are the methods for converting a string to an array. ... An in-built PHP method is used to convert a string into an array by breaking the string into smaller sub-strings of uniform length and storing them in an array.
๐ŸŒ
GeeksforGeeks
geeksforgeeks.org โ€บ php โ€บ split-a-string-into-an-array-of-words-in-php
Split a String into an Array of Words in PHP - GeeksforGeeks
July 23, 2025 - In this approach we splits a string into words by iterating through each character, appending non-whitespace characters to word variable and adding completed words to words when a whitespace character is encountered. Example: This example shows the use of for loop for splitting the string into an array. ... <?php $string = "Hello geek welcome to, GFG!"; $words = []; $word = ''; for ($i = 0; $i < strlen($string); $i++) { $char = $string[$i]; // Check for whitespace character if ($char !== ' ') { $word .= $char; // Append character to current word } else { if (!empty($word)) { $words[] = $word; // Add completed word to array $word = ''; // Reset current word } } } if (!empty($word)) { $words[] = $word; // Add last word if any } print_r($words); ?>
๐ŸŒ
Scaler
scaler.com โ€บ home โ€บ topics โ€บ php string split
How to Split a String into an Array in PHP? - Scaler Topics
April 12, 2024 - Explanation In this example, the variable $string holds the value "Hello". The str_split() function is called with the $string as its argument. This function splits the string into an array, where each element of the array corresponds to a single character from the original string.
๐ŸŒ
GeeksforGeeks
geeksforgeeks.org โ€บ php โ€บ how-to-convert-query-string-to-an-array-in-php
How to Convert Query String to an Array in PHP? - GeeksforGeeks
July 23, 2025 - This PHP method converts a query string to an array using parse_url to extract query parameters and parse_str to convert them into an associative array.
๐ŸŒ
GeeksforGeeks
geeksforgeeks.org โ€บ php โ€บ split-a-comma-delimited-string-into-an-array-in-php
Split a comma delimited string into an array in PHP - GeeksforGeeks
July 11, 2025 - After the loop add the last word to the array to complete the split. ... <?php $string = "welcome, to, gfg"; $array = []; $current_word = ""; // Loop through each character in the string for ($i = 0; $i < strlen($string); $i++) { if ($string[$i] === ',') { // Add the current word to the array and reset it $array[] = $current_word; $current_word = ""; } else { // Append character to the current word $current_word .= $string[$i]; } } // Add the last word to the array $array[] = $current_word; print_r($array); ?>
๐ŸŒ
Parthpatel
parthpatel.net โ€บ home โ€บ php โ€บ php: how to convert array to string using implode()
PHP: How to Convert Array to String using implode() | Parth Patel - a Web Developer
November 18, 2020 - If you want to use both values and index while joining array to string, then it gets complex. There are many ways to achieve this. Also, it depends how you want to represent the index and values in string. The implode() doesn't have any native functionality to handle such situations therefore, we will use multiple PHP functions including implode() function to achieve the same.
๐ŸŒ
Intellipaat
intellipaat.com โ€บ home โ€บ blog โ€บ converting a string to an array in php
Convert String to Array in PHP using Different Functions
August 25, 2025 - Learn how to convert a string to array in PHP using functions like explode() and str_split(). Includes code examples and practical use cases.