This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revisionLast revisionBoth sides next revision | ||
webseite:php:xmlreader [2020/12/21 18:58] – lunetikk | webseite:php:xmlreader [2020/12/21 19:39] – lunetikk | ||
---|---|---|---|
Line 18: | Line 18: | ||
$xml=simplexml_load_file("< | $xml=simplexml_load_file("< | ||
$news = $xml-> | $news = $xml-> | ||
+ | |||
//#### Create Table #### | //#### Create Table #### | ||
echo '< | echo '< | ||
+ | |||
//#### Foreach news article do #### | //#### Foreach news article do #### | ||
foreach($news as $a) | foreach($news as $a) | ||
Line 40: | Line 40: | ||
} | } | ||
echo "</ | echo "</ | ||
+ | |||
//#### Function to limit text to 250 chars #### | //#### Function to limit text to 250 chars #### | ||
//#### https:// | //#### https:// | ||
function truncate($string, | function truncate($string, | ||
$string = trim($string); | $string = trim($string); | ||
+ | |||
if(strlen($string) > $length) { | if(strlen($string) > $length) { | ||
$string = wordwrap($string, | $string = wordwrap($string, | ||
Line 51: | Line 51: | ||
$string = $string[0] . $append; | $string = $string[0] . $append; | ||
} | } | ||
+ | |||
return $string; | return $string; | ||
} | } | ||
+ | |||
?> | ?> | ||
</ | </ |