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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T13:15:46+00:00 2026-05-24T13:15:46+00:00

I have an array: $a = array(‘foo’ => ‘fooMe’); and I do: print_r($a); which

  • 0

I have an array:

$a = array('foo' => 'fooMe');

and I do:

print_r($a);

which prints:

Array ( [foo] => printme )

Is there a function, so when doing:

needed_function('    Array ( [foo] => printme )');

I will get the array array('foo' => 'fooMe'); back?

  • 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-24T13:15:47+00:00Added an answer on May 24, 2026 at 1:15 pm

    I actually wrote a function that parses a “stringed array” into an actual array. Obviously, it’s somewhat hacky and whatnot, but it works on my testcase. Here’s a link to a functioning prototype at http://codepad.org/idlXdij3.

    I’ll post the code inline too, for those people that don’t feel like clicking on the link:

    <?php
         /**
          * @author ninetwozero
          */
    ?>
    <?php
        //The array we begin with
        $start_array = array('foo' => 'bar', 'bar' => 'foo', 'foobar' => 'barfoo');
    
        //Convert the array to a string
        $array_string = print_r($start_array, true);
    
        //Get the new array
        $end_array = text_to_array($array_string);
    
        //Output the array!
        print_r($end_array);
    
        function text_to_array($str) {
    
            //Initialize arrays
            $keys = array();
            $values = array();
            $output = array();
    
            //Is it an array?
            if( substr($str, 0, 5) == 'Array' ) {
    
                //Let's parse it (hopefully it won't clash)
                $array_contents = substr($str, 7, -2);
                $array_contents = str_replace(array('[', ']', '=>'), array('#!#', '#?#', ''), $array_contents);
                $array_fields = explode("#!#", $array_contents);
    
                //For each array-field, we need to explode on the delimiters I've set and make it look funny.
                for($i = 0; $i < count($array_fields); $i++ ) {
    
                    //First run is glitched, so let's pass on that one.
                    if( $i != 0 ) {
    
                        $bits = explode('#?#', $array_fields[$i]);
                        if( $bits[0] != '' ) $output[$bits[0]] = $bits[1];
    
                    }
                }
    
                //Return the output.
                return $output;
    
            } else {
    
                //Duh, not an array.
                echo 'The given parameter is not an array.';
                return null;
            }
    
        }
    ?>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have array of objects. I want to write method wich i will use
I have a multi-dimensional array right now that looks like this: function art_appreciation_feeds() {
Let's say I have array like {12,23,,34,22,,,12} If there are 5 items as than
how to compare value in an array? I have array named list which contains
I have array like this: array('1224*', '543*', '321*' ...) which contains about 17,00 "masks"
I have array of select tag. <select id='uniqueID' name=status> <option value=1>Present</option> <option value=2>Absent</option> </select>
I have array like this: $path = array ( [0] => site\projects\terrace_and_balcony\mexico.jpg [1] =>
if i have array array[0] = jack; array[1] = jill; array[2] = lisa; array[2]
An array is defined of assumed elements like I have array like String[] strArray
Let's say I have array of bytes: byte[] arr = new byte[] { 0,

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.