Jump to content

expecting function to return an html table, it returns integer 0 instead


johnmerlino

Recommended Posts

Hey all,

 

this function returns 0, rather than a string consisting of html tags:

function cost_per_distance_table($distance,$divisor){
	$str = "";
	$str += "<table>";
	$str += "<tr>";
	$str += "<td>Distance</td>";
	$str += "<td>Cost</td>";
	$str += "</tr>";
	while($distance <= 250){ 
		$str += "<tr>";
		$str += "<td>" . (string)$distance . "</td>\n";
		$str += "<td>" . (string)($distance/$divisor) . "</td>\n";
		$str += "</tr>";
		$distance += 50;
	}
	$str += "</table>";
	return $str;
}
      
      echo cost_per_distance_table(50,10); 

 

Not sure why. Thanks for response.

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.