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 6849001
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T00:56:13+00:00 2026-05-27T00:56:13+00:00

I need to grab a json-string from this page: https://retracted.com If you view the

  • 0

I need to grab a json-string from this page: https://retracted.com

If you view the source, I json-string starts after var mycarousel_itemList =. I need to parse this string as a correct json-array in my php-script.

How can this be done?

EDIT: I’ve managed to pull this off using explode, but the method is ugly as heck. Is there no build-in function to translate this json-string to a array?

To clarify: I want the string I grab (which is correct json) to be converted into a php-array.

  • 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-05-27T00:56:14+00:00Added an answer on May 27, 2026 at 12:56 am

    The JSON in the script block is invalid and needs to be massaged a bit before it can be used in PHP’s native json_decode function. Assuming you have already extracted the JSON string from the markup (make sure you exclude the semicolon at the end):

    $json = <<< JSON
    [ { address: 'Arnegårdsveien 32', … } ]
    JSON;
    
    var_dump(
        json_decode(
            str_replace(
                array(
                    'address:',
                    'thumb:',
                    'description:',
                    'price:',
                    'id:',
                    'size:',
                    'url:',
                    '\''
                ),
                array(
                    '"address":',
                    '"thumb":',
                    '"description":',
                    '"price":',
                    '"id":',
                    '"size":',
                    '"url":',
                    '"'
                ),
                $json
            )
        ,
        true
        )
    );
    

    This will then give an array of arrays of the JSON data (demo).

    In other words, the properties have to be double quoted and the values need to be in double quotes as well. If you want an array of stdClass objects instead for the “{}” parts, remove the true.

    You can do this either with str_replace as shown above or with a regular expression:

    preg_match('
        (.+var mycarousel_itemList = ([\[].+);.+function?)smU',
        file_get_contents('http://bolig…'),
        $match
    );
    $json = preg_replace(
        array('( ([a-z]+)\:)sm', '((\'))'),
        array('"$1":', '"'),
        $match[1]
    );
    var_dump(json_decode($json, true));
    

    The above code will fetch the URL, extract the JSON, fix it and convert to PHP (demo).

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I grab a JSON string from an API using jQuery's dataType 'jsonp'. The operation
I need to grab the latest post from a facebook like page. I'm an
I need to grab some content from an HTML (XHTML valid) page. I grab
I need to grab the values of a JSON string stored within a function
Im new to JSON and php. I need to grab the lat and lng
I need to grab the base64-encoded representation of the ViewState . Obviously, this would
I am using this jquery ui autocomplete but i need to grab the data
I am performing the following AJAX call: $(document).ready(function() { $.getJSON('https://sendgrid.com/api/user.stats.json', { 'api_user': 'me@mydomain.com', 'api_key':
I need to grab an attribute of a custom HTML tag. I know this
I need to grab a string like /html/body/a i need to check the last

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.