๐Ÿ”’ 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
  • 427
    Views
  • 4
    Participants
Last reply from:
Clarie

Online now

Members online
984
Guests online
1,417
Total visitors
2,401

Forum statistics

Threads
2,276,208
Posts
28,968,320
Members
1,231,166
Latest member
williamfreede
Back
Top