1

I var_dump and array and got a value printed, how do i create an array from the result. the array is generated a method and i clearly dont know the structure of the array.

Array ( [0] => gapiReportEntry Object ( [metrics:gapiReportEntry:private] => Array ( [visits] => 4 ) [dimensions:gapiReportEntry:private] => Array ( [year] => 2011 [month] => 07 [day] => 20 ) ) [1] => gapiReportEntry Object ( [metrics:gapiReportEntry:private] => Array ( [visits] => 32 ) [dimensions:gapiReportEntry:private] => Array ( [year] => 2011 [month] => 07 [day] => 13 ) ))

the above is the var_dump result.

I tried to recreate it

$nuarr = array(); $nuarr[0] = array("metrics:gapiReportEntry:private"=>array("visits"=>4),"dimensions:gapiReportEntry:private"=>array("year"=>2011,"months"=>07,"day"=>20)); $nuarr[1] = array("metrics:gapiReportEntry:private"=>array("visits"=>10),"dimensions:gapiReportEntry:private"=>array("year"=>2011,"months"=>07,"day"=>10));

but it doesn't return the same var_dunp value.

Could anyone structure the array for me...

3 Answers 3

1

Just assign the new array using assignment operator =

$nuarr = $first_array;

Now the $nuarr is an identical copy of your $first_array.

You can also use the var_export

$nuarr = var_export($first_array, true);
Sign up to request clarification or add additional context in comments.

1 Comment

hi shakthi could you help me to call the last value of the array node 0. some thing like this array[0]['gapiReportEntry']['metrics']['visits'], i couldn't able to call any value from the array, help me out.
0

You don't mention why you want to do this. If what you need is just an array-to-string and vice versa mechanism, consider using serialize() and unserialize() rather than var_dump().

2 Comments

hi pelle could you help me to call the last value of the array node 0. some thing like this array[0]['gapiReportEntry']['metrics']['visits'], i couldn't able to call any value from the array or it can be termed i dont know, help me out..
Sorry, I don't understand your question at all. Please rephrase.
0

If you want to print out an array so that you can clearly see its structure, couldn't you do the following?

echo '<pre>'.print_r($array,1)',</pre>';

I know it isn't using var_dump(), but it would produce the desired result, wouldn't it?

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.