0
私はこのコードを持っています。データをCSVからSVGに変換するすべての要素
<?php
$csv = "
4841625010111,Marimea,42,2,350,,C221980;[email protected]\n
4841625010112,Marimea,44,2,350,,C221980;[email protected]\n
4841625010113,Marimea,46,2,350,,C221980;[email protected]\n
4841625010114,Marimea,48,2,350,,C221980;009025849440325421:[email protected]\n
4841625010115,Marimea,50,2,350,,C221980;[email protected]\n
4841625010116,Marimea,52,2,350,,C221980;00902584944032524<[email protected]\n
4841625010117,Marimea,54,2,350,,C221980;0090258494403221250<@\n
";
$csv_arr = explode("\n", $csv);
echo "<svg version=\"1.1\" id=\"Layer_1\" xmlns=\"http://www.w3.org/2000/svg\" xmlns:xlink=\"http://www.w3.org/1999/xlink\" x=\"0px\" y=\"0px\"\n";
echo " width=\"252px\" height=\"144px\" viewBox=\"0 0 252 144\" enable-background=\"new 0 0 252 144\" xml:space=\"preserve\">\n";
foreach ($csv_arr as $card) {
$row = explode(",", $card);
echo "<text display=\"block\">\n";
echo "Size<tspan x=\"0\" y=\"0\" font-family=\"'Arial\" font-size=\"12\">{$row[2]}</tspan>\n";
echo "Pret<tspan x=\"0\" y=\"14.4\" font-family=\"'Arial'\" font-size=\"12\">{$row[4]}</tspan>\n";
echo "<tspan x=\"0\" y=\"28.8\" font-family=\"'Arial'\" font-size=\"12\">{$row[2]}</tspan>\n";
echo "<tspan x=\"0\" y=\"43.2\" font-family=\"'Barcode'\" font-size=\"12\">{$row[6]}</tspan></text>\n";
echo "<tspan x=\"0\" y=\"43.2\" font-family=\"'Arial'\" font-size=\"12\">{$row[3]}</tspan></text>\n";
echo "<\br><\br><\br><\br>";
}
echo "</svg>";
?>
となりました。すべての部分がインラインです。私は新しい行で必要です。