我被 for 循环卡住了,因为我没有得到正确的语法,我需要它在 html 和 foreach 循环之间运行,以便它可以回显,我正在尝试修改我拥有的 wp 主题之一的简码,我是 php 新手,遇到语法问题,非常感谢您的帮助
function testimonial( $atts, $content = null ) {
$GLOBALS['tms_count'] = 0;
$i = 1;
$randomid = rand();
do_shortcode( $content );
if( is_array( $GLOBALS['tmss'] ) ){
foreach( $GLOBALS['tmss'] as $tms ){
$wrp[] = '<div>
<div class="tm">
<p>'.$tms['content'].'</p>
<div>'.$tms['author'].'</div>
<div class="nonedi">
<div><strong>Services</strong></div>
<meta content="'.$tms['date'].'">'.$tms['date2'].'
</div>
<span>'.$tms['rating'].'</span>
Rating:<span class="star-img">'
/* This is where things go worng as my syntax is not right */
.$tms['rating'] = $test;
for ($x=1; $x==$test; $x++){
echo "<img>";
}
'</span>
</div>';
$i++;
}
$return = '<div class="nonedi">
<div class"name">Services</div>
</div>
<div class="testimonial-wrapper">'.implode( "\n", $wrp ).'</div>';
}
return $return;
}
function tms( $atts, $content = null) {
extract(shortcode_atts(array(
'author' => '',
'date' => '',
'date2' => '',
'rating' => '',
), $atts));
$x = $GLOBALS['tms_count'];
$GLOBALS['tmss'][$x] = array( 'author' => sprintf( $author, $GLOBALS['tms_count'] ), 'date' => $date, 'date2' => $date2, 'rating' => $rating, 'content' => $content );
$GLOBALS['tms_count']++;
}