Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7720535
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T03:41:59+00:00 2026-06-01T03:41:59+00:00

I have this json string: $row[‘medium’] = {\medium\:13|17|1|14, \medium_sub\:21}; now I want to make

  • 0

I have this json string:

$row['medium'] = "{\"medium\":13|17|1|14, \"medium_sub\":21}";

now I want to make an array from the “medium” part:

$medium_arr = $row['medium']->{'medium'};   

$medium_arr =
explode("|", $medium_arr);

print_r($medium_arr); //This is empty

when I make an array with zero’s like (but I know, this makes no sense)

$row['medium'] = "{\"medium\":1301701014, \"medium_sub\":21}";
$medium_arr = explode("0", $medium_arr);

print_r($medium_arr); //This gives 4 results

how is it possible that I can not use the explode in a proper way?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-01T03:42:01+00:00Added an answer on June 1, 2026 at 3:42 am

    If that is your real JSON string, it isn’t valid. The pipe-delimited string must be quoted. Using zeros worked because it resulted in a numeric value for medium that didn’t need quotes.

    $row['medium'] = "{\"medium\":\"13|17|1|14\", \"medium_sub\":21}";
    

    It can then be decoded properly with json_decode().

    var_dump(json_decode($row['medium']));
    object(stdClass)#1 (2) {
      ["medium"]=>
      string(10) "13|17|1|14"
      ["medium_sub"]=>
      int(21)
    }
    
    $json = json_decode($row['medium']);
    $medium_arr = $json->medium;
    $medium_arr = explode("|", $medium_arr);
    var_dump($medium_arr);
    
    array(4) {
      [0]=>
      string(2) "13"
      [1]=>
      string(2) "17"
      [2]=>
      string(1) "1"
      [3]=>
      string(2) "14"
    }
    

    Update

    I would add that instead of using a delimited string, if you have the ability to modify the JSON, you ought to use an array for those values in the JSON as:

    $row['medium'] = "{\"medium\":[13,17,1,14], \"medium_sub\":21}";
    var_dump(json_decode($row['medium]));
    
    // Now they're already an array!
    object(stdClass)#1 (2) {
      ["medium"]=>
      array(4) {
        [0]=>
        int(13)
        [1]=>
        int(17)
        [2]=>
        int(1)
        [3]=>
        int(14)
      }
      ["medium_sub"]=>
      int(21)
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am getting JSON string from website. I have data which looks like this
I receive this JSON string (part of a really big one) back from an
Possible Duplicate: How to parse JSON in JavaScript I have this JSON string: [{title:
I have this JSON response string: {d:{\ID_usuario\:\000130\,\Nombre\:null,\Vipxlo\:0,\Provmun\:null,\Descuentos\:null,\Listaviplocal\:null}}` With this code: - (void)connectionDidFinishLoading:(NSURLConnection *)connection {
I have a YQL output JSON string at this URL: YQL JSON I found
I have a JSON string that looks like this: { package1: { type: envelope,
I have to create JSON string from database values and push it back to
I have a single array json string containing data: [{Name:John,Age:22}, {Name:Jack,Age:56}, {Name:John,Age:82}, {Name:Jack,Age:95}] I
I want foreach a row from database and get value it, but have error:
I have a JSON array coming in from the server with an array of

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.