dimanche 29 novembre 2015

PHP how to put an if statement inside an echo block

I have the following if statement:

<?php if ( isset ( $prfx_stored_meta['wedding-user'] ) ) selected( $prfx_stored_meta['wedding-user'][0], 'select-one' ); ?>

which I need to insert into this echo statement:

$users = get_users();
$i = 0;
// Array of WP_User objects.
foreach ( $users as $user ) {
    echo "<option value='select-$i' >" . esc_html( $user->display_name ) . "</option>";
    $i++;
}

Just before closing the tag I'm not sure how to add an if statement inside of an echo

Aucun commentaire:

Enregistrer un commentaire