Jump to content

Replace array values with single variable


MFA

Recommended Posts

I am wondering how to replace several values in an array with a single variable. I have tried just simply creating a variable for all the values within the array (e.g. $variable = $round1.",".$round2.",".$round3) and substituiting that in however it doesn't work as the array understands the comma's literally and outputs them on the page. The original line of code is below. Thank you.

$myData->addPoints(array($round1,$round2,$round3),"Frequency");

 

 

Your question is not clear, but I think you either want to list() or serialize() your data.  I think I remeber hearing somewhere that serialize and arrays don't get on the best, but I could well be getting mixed up.

 

My question to you is - do you need to use an array in the first place?

Yes I know, it's difficult to explain. Unfortunately, I have to use an array, this is template code from pChart and I have to fill in the array values as they represent the values of the bar graphs.

I am still not sure how to go about this using the list() function.

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.