Functions Arrays While loops


<!-- WordPress Functions -->
<?php bloginfo('name') ?><br>
<?php bloginfo('title') ?><br>
<?php bloginfo('description') ?><br>

<!-- Arrays -->
<?php
    $names = array('Brad', 'John', 'Jane', 'Sofia');
?>
<p>Hi, my name is <?php echo $names[0]; ?></p>
<p>Hi, my name is <?php echo $names[1]; ?></p>
<p>Hi, my name is <?php echo $names[2]; ?></p>
<p>Hi, my name is <?php echo $names[3]; ?></p>

<!-- Looping -->
<?php 
    $count = 1;
    while($count < 10) {
        echo "<li>$count</li>";
        $count++;
    }
?>

<!-- Looping Arrays-->
<?php
    $names_loop = array('Brad', 'John', 'Jane', 'Sofia');
    $count_loop = 0;
    while($count_loop < count($names_loop)) {
        echo "<li>Hi, my name is $names_loop[$count_loop]</li>";
        $count_loop++;
    }
?>
Scroll to Top