Jump to content

pieces of array into variable


dubc07

Recommended Posts

I'm wanting to put the following into variables.

 

 

 
$content = array(
			"html" => "<b>$name</b><br>Solo", // Display 'Phsychology: Room 404'
			"style" => "background-color: $color", // use style property to change the background color
			"interval" => $intrv // set the interval for 2hrs 
			);

$tilt = array($time =>$content);
$edz = ''.$plane.' =>';							
$lst =")),";	////to close the array/// having the most problems here.			
$first = $edz.$tilt.$lst;
echo $first;
//the end results should look like this 
  0 => array(
		// Adds a class at 11am (1100 hours)
		700 => array(
			"html" => "<b>Airplane Down </b><br>Maintenance", // Display 'English 101: Room 235'
			"style" => "background-color: #FFFFFF", // use style property to change the background color
			 "interval" => 1400 // set the interval for 2hrs
  )
  ),
  ////im wanting to put the array into a variable so that i can put the output as $first////

$classes_arr =	array($first);

Link to comment
https://forums.phpfreaks.com/topic/115286-pieces-of-array-into-variable/
Share on other sites

I'm wanting to put the following into variables.

 

 

 
$content = array(
			"html" => "<b>$name</b><br>Solo", // Display 'Phsychology: Room 404'
			"style" => "background-color: $color", // use style property to change the background color
			"interval" => $intrv // set the interval for 2hrs 
			);

$tilt = array($time =>$content);
$edz = ''.$plane.' =>';							
$lst =")),";	////to close the array/// having the most problems here.			
$first = $edz.$tilt.$lst;
echo $first;
//the end results should look like this 
  0 => array(
		// Adds a class at 11am (1100 hours)
		700 => array(
			"html" => "<b>Airplane Down </b><br>Maintenance", // Display 'English 101: Room 235'
			"style" => "background-color: #FFFFFF", // use style property to change the background color
			 "interval" => 1400 // set the interval for 2hrs
  )
  ),
  ////im wanting to put the array into a variable so that i can put the output as $first////

$classes_arr =	array($first);

You need to learn the proper syntax for arrays. I guess you mean:

$content = array(
			"html" => "<b>$name</b><br>Solo", // Display 'Phsychology: Room 404'
			"style" => "background-color: $color", // use style property to change the background color
			"interval" => $intrv // set the interval for 2hrs 
			);

$time = 700;

$array[][$time] = $content;

//or

$array = array(0 => array($time => $content));

 

 

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.