"4", "2" => "2", "3" => "3")I use php 5.4. 1:Just use json_decode.$dd = json_decode($mystring, true);" name="description" /> "4", "2" => "2", "3" => "3")I use php 5.4. 1:Just use json_decode.$dd = json_decode($mystring, true);" />

Explode string into array with key and value


I've a string like this:

$mystring = '{"1":"4","2":"2","3":"3"}';

I need to explode to something like this:

array( "1" => "4", "2" => "2", "3" => "3" )

I use php 5.4.


Just use <a href="http://php.net/manual/en/function.json-decode.php" rel="nofollow">json_decode</a>.

$dd = json_decode($mystring, true); var_export($dd);


you "string" is very like json so maybe try <a href="http://php.net/manual/en/function.json-decode.php" rel="nofollow">json_decode()</a>


you should use the json decode function, your string looks like json. The second argument tells to make it as an array, not an object.

json_decode($mystring, true);


  • Laravel 5.3 : Passport Implementation - {“error”:“invalid_client”,“message”:“Client authentication f
  • PHP script receives GET instead of POST REQUEST
  • PHP replace preceding substrings of some other substring
  • Iterating through JSON using System.Json
  • Ruby regex: extract a list of urls from a string
  • PHP not converting JSON using 'json_decode()'
  • ng-pattern that allows decimal ratios
  • How to access list of email accounts with cPanel API?
  • A simple datepicker in VueJS
  • How to make Plotly chart with year mapped to line color and months on x-axis
  • How to parsing NSDate to RFC 822 always use in English?
  • iOS Date formatting
  • Exposing an enum in a QML signal
  • I want to generate 8 combinations of names from a column in an R data frame based on conditions from
  • How to separate filename from path? basename() versus preg_split() with array_pop()
  • testing a POST using phpunit in laravel 4
  • Criterion causing memory consumption to explode, no CAFs in sight
  • nodemcu custom firmware build problems
  • SAXReader not re-ecape characters
  • d3 v4 drag and drop with TypeScript
  • Why does access(2) check for real and not effective UID?
  • Illegal mix of collations for operation for date/time comparison
  • Splitting given String into two variables - php
  • Upload files with Ajax and Jquery
  • Do I've to free mysql result after storing it?
  • Rearranging Cells in UITableView Bug & Saving Changes
  • R: gsub and capture
  • AT Commands to Send SMS not working in Windows 8.1
  • A cron job substitute?
  • Windows forms listbox.selecteditem displaying “System.Data.DataRowView” instead of actual value
  • json Serialization in asp
  • Benchmarking RAM performance - UWP and C#
  • Angular 2 constructor injection vs direct access
  • IndexOutOfRangeException on multidimensional array despite using GetLength check
  • apache spark aggregate function using min value
  • Sorting a 2D array using the second column C++
  • Observable and ngFor in Angular 2
  • How to Embed XSL into XML
  • UserPrincipal.Current returns apppool on IIS
  • Conditional In-Line CSS for IE and Others?