[英]Why php code does not echo anything?
<?php
$svg_file = file_get_contents("fonts/font.svg");
$font = new DOMDocument();
$font->load($svg_file);
$glyphs = $font->getElementsByTagName('glyph');
foreach($glyphs as $g) {
echo $g->getAttribute('glyph-name');
}
?>
Where am i going wrong in above code???我在上面的代码中哪里出错了??? it does not echo anything, trying on localhost它没有回显任何内容,尝试使用本地主机
Try this:尝试这个:
$font = new DOMDocument();
$font->load("fonts/font.svg");
$glyphs = $font->getElementsByTagName('glyph');
foreach($glyphs as $g) {
echo $g->getAttribute('glyph-name');
}
UPDATE:更新:
$font = new DOMDocument();
$font->load("fonts/font.svg");
$glyphs = $font->getElementsByTagName('glyph');
$arr_names = array();
foreach($glyphs as $g) {
$arr_names[] = $g->nodeValue;
}
$sort($arr_names);
foreach($arr_names as $name){
echo $name;
}
UPDATE:更新:
$font = new DOMDocument();
$font->load("fonts/font.svg");
$glyphs = $font->getElementsByTagName('glyph');
$arr_names = array();
foreach($glyphs as $g) {
$arr_names[] = $g->nodeValue;
}
sort($arr_names);
foreach($arr_names as $name){
echo $name;
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.