Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
stdClass Object ( [tip1] => Array ( [text] => <p>Test text</p> [format] => 1 ) )
我正在尝试使用数组循环对象对象
for ($i=1;$i<=10;$i++) { echo $fromform->{'tip$i'}['text']; }
从来没有工作过?
使用双引号,
echo $fromform->{"tip$i"}['text'];
或者像这样用单引号,
$fromform->{'tip'.$i}['text'];
php 变量永远不会在单引号内被解析
用双引号替换它
for ($i=1;$i<=10;$i++) { echo $fromform->{"{tip$i}"}['text']; }