Jump to content

[SOLVED] Loop


shamuraq

Recommended Posts

Scenario:

 

I need to loop line drawn in svg:

 

$lebar = 800/10;
for(i=0;i<$lebar;i++){
	$output .= "<path class=\"SamplePath\" d=\"M\"$i\" 0 L\"$i\" 800\"></path>\n";
}


 

i can't seem to get the loop till 80 lines are drawn vertically($lebar=800/10)....

 

Thanx in advance...

 

Link to comment
https://forums.phpfreaks.com/topic/160769-solved-loop/
Share on other sites

btw, these is the entire code...

really need help to solve this:

 

<?php

header("Content-type: image/svg+xml");
$output .="<?xml version=\"1.0\" standalone=\"no\"?>";
$output .="<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\"
\"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\">";

$output .= "<svg width=\"1028\" height=\"1024\" 
 xmlns=\"http://www.w3.org/2000/svg\" version=\"1.1\">";

//class style sheet
$output .= "<style type=\"text/css\">
<![CDATA[
    .Border { fill:none; stroke:#a4a4a4; stroke-width:1; stroke-dasharray: 5, 3, 9, 2; }
    .Connect { fill:#505050; stroke:#888888; stroke-width:2 }
    .SamplePath { fill:none; stroke:#CCCCCC; stroke-width:1 }
    .EndPoint { fill:none; stroke:#888888; stroke-width:2 }
    .CtlPoint { fill:#888888; stroke:none }
    .AutoCtlPoint { fill:none; stroke:blue; stroke-width:4 }
    .Label {font-family: Arial }  
]]>
</style>";

$lebar = 80;
for($i=0; $i<$lebar; $i++{
	$output .= "<path d=\"M$i 0 L$i 800\"></path><br>\n";
}

//$lebar = 80;
//$output .= "<path class=\"SamplePath\" d=\"M$lebar 0 L$lebar 800\"></path>\n";

$output .= "</svg>\n";
print $output;

?>

The syntax for producing path is:

//M is moving drawing pointer to x and y axis
//L means line to x and y axis
//Z is to close the path. Means joining the last point drawn to the first point.
<path d="M 100 100 L 300 100 L 200 300 z"></path> //

What i want is to duplicate the point drawn....

Link to comment
https://forums.phpfreaks.com/topic/160769-solved-loop/#findComment-848490
Share on other sites

Btw where do i put:

 

error_reporting(E_ALL);

ini_set('display_errors', 1);

 

can i place it at the last line before the "?>"

Nope, you put it at the very top of your script, immediately after the <?php

 

You're telling PHP to display all errors... not much point in doing that after the script has finished running and all the errors have already occurred, tell it how it should report any errors before the errors occur

Link to comment
https://forums.phpfreaks.com/topic/160769-solved-loop/#findComment-848524
Share on other sites

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.