🔒 Closed PHP | Question #3

What is the index of the string element "peace"

  • 3

    Votes: 0 0.0%
  • 4

    Votes: 2 100.0%
  • 5

    Votes: 0 0.0%
  • This array does not have indices.

    Votes: 0 0.0%

  • Total voters
    2
Status
Not open for further replies.
4 po

1648267871482.png


Explanation: the first value of the array starts at index 0
 
PHP:
<?php
$index = array("hello", "3", "-3.9","world", "peace");
echo "index 0 => {$index[0]},<br/>
index 1 => {$index[1]},<br/>
index 2 => {$index[2]}, <br/>
index 3 => {$index[3]}, <br/>
index 4 => {$index[4]}";
?>


Output:
index 0 => hello,
index 1 => 3,
index 2 => -3.9,
index 3 => world,
index 4 => peace
 
bat di mo nlng i run yung code kung gusto mong malaman ang sagot?
Minsan kasi nag error, begineer palang po kasi ako. Kaya sa mga codes na naproprovide dito pinag-aaralan ko din naman po. 🙂

PHP:
<?php
$index = array("hello", "3", "-3.9","world", "peace");
echo "index 0 => {$index[0]},<br/>
index 1 => {$index[1]},<br/>
index 2 => {$index[2]}, <br/>
index 3 => {$index[3]}, <br/>
index 4 => {$index[4]}";
?>


Output:
index 0 => hello,
index 1 => 3,
index 2 => -3.9,
index 3 => world,
index 4 => peace
Salamat po
 
Status
Not open for further replies.

About this Thread

  • 5
    Replies
  • 433
    Views
  • 4
    Participants
Last reply from:
Clarie

Trending Topics

Online now

Members online
381
Guests online
976
Total visitors
1,357

Forum statistics

Threads
2,286,940
Posts
29,041,315
Members
1,217,274
Latest member
scrapersam
Back
Top