All pastes #269017 Raw Edit

Mine

public text v1 · immutable
·published 2006-12-06 05:50 UTC
rendered paste body
<?php
// In the graph class....

public function get_graph_values($input) {
	$answers_array = array();
	
	for($i = -10.0; $i <= 11.0; $i = ($i + 0.1)){
		$evaluating_input = str_replace('x', '(' . $i . ')', $input);
		
		$evaluating_input = '$evaluated_input = ' . $evaluating_input . ';';
		eval($evaluating_input);
		
		$y = $evaluated_input;
		$x = $i;
		
		$answers_array[$x] = $y;
	}
	return $answers_array;
}


// On a test page, after creating $graph as an instance of the graph class...

$answers_array = $graph->get_graph_values($input_function);

print_r($answers_array);
die();
?>