Best way to create SVG from database? (Using PHP)
&lt;?php
$formats = array(
    '1' =&gt; array(
        'x1' =&gt; 820,
        'y1' =&gt; 120
    ),
    '2' =&gt; array(
        'x1' =&gt; 905,
        'y1' =&gt; 180
    )
);
?&gt;

&lt;?php foreach( $formats as $key =&gt; $format ) : ?&gt;
    &lt;?php if ( in_array( (int) $key, $services ) ) : ?&gt;
        &lt;line x1="&lt;?php print $format['x1']; ?&gt;" y1="&lt;?php print $format['y1']; ?&gt;" /&gt;
    &lt;?php endif; ?&gt;
&lt;?php endforeach; ?&gt;


I didn't do it for every field, but you get the idea.

This is tedious to write the array. But you have to write it somewhere. If there is no logic, the computer can't guess.

I think it's easier to read/write a simple array than all this XML though.