Jump to content

Reformatting an array and printing the result.


ridiculous

Recommended Posts

Hello.

 

 

 

 

 

 

 

 

 

 

I have an array called $value which, when echoed, returns [12345].

Instead, I desire to reformat this array so that it prints or echoes in the following format: ["1","2","3","4","5"].

 

So far, I have:

 

echo """ , $value , "&quot, ";  ////["1","2","3","4","5"].

 

This yields my desired result, but I want to encapsulate that result in a variable.

 

I have tried

 

$k = echo """ , $value , "&quot, ";

 

with no success.

My objective is to have 

 

echo $k; ///return "1","2","3","4","5"

 

 

 

 

Any guidance is much appreciated.

 

 

 

Thanks! Actually, I ended up getting what I wanted by doing this:

 

$k =  "&quot $value &quot,";
print $k;

 

That returns each of the values from my array formatted as desired.

However, now I am trying to inject this variable into an array like so:

 

 

$chart[ 'chart_data' ] = array ( array ( "","1","2","3","4","5", ), array (print $k) );

 

 

I guess I can't just write "print $k" as a value for the array. Any ideas on how to have php parse

 

 

array ($k) 

 

like it would

 


array ("",1,2,3,4,5)

 

 

Thanks for the feedback.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.