note 127003 added to control-structures.alternative-syntax
| From: | toxyy at main dot php dot net | Date: | Fri, 22 Apr 2022 22:00:32 +0000 |
| Subject: | note 127003 added to control-structures.alternative-syntax | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-218303@lists.php.net to get a copy of this message | ||
I feel compelled to give a more elegant way using heredoc than the other comment:
<ul>
<?php foreach($list as $item): echo
<<<ITEM
<li id="itm-$item[number]">Item $item[name]</li>
ITEM;
endforeach; ?>
</ul>
Which works better with multi line blocks, as you only need one overall php tag.
(please don't omit the closing </li> tag despite it being legal, personal preference)
----
Server IP: 45.112.84.4
Probable Submitter: 80.90.5.135 (proxied: 24.96.135.141)
----
Manual Page -- https://php.net/manual/en/control-structures.alternative-syntax.php
Edit -- https://main.php.net/note/edit/127003
Del: integrated -- https://main.php.net/note/delete/127003/integrated
Del: useless -- https://main.php.net/note/delete/127003/useless
Del: bad code -- https://main.php.net/note/delete/127003/bad+code
Del: spam -- https://main.php.net/note/delete/127003/spam
Del: non-english -- https://main.php.net/note/delete/127003/non-english
Del: in docs -- https://main.php.net/note/delete/127003/in+docs
Del: other reasons-- https://main.php.net/note/delete/127003
Reject -- https://main.php.net/note/reject/127003
Search -- https://main.php.net/manage/user-notes.php