Jump to content

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.

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.