Jump to content

[TINY HELP] in_array


aub
Go to solution Solved by aub,

Recommended Posts

Hi guys, just need your tiny help. I'm learning as you can see.

The question says: 
Create a script to check if the value "Sydney" is stored in the following array (hint: use function: in_array) 
$cities = array("New York", "London", "Sydney", "Paris", "Brisbane")

(Note: you must print the ending result)

 

This is my code:

<?php
$cities = array("New York", "London", "Sydney", "Paris", "Brisbane")
if (in_array("Sydney", $cities)) {
echo "Yes, Sydney is stored!";
}
?>

I cant fix the problem? 

Your help would be lovely.

Thanks! 

Link to comment
Share on other sites

  • Solution

 

You have a left of the semi-colon at the end of the second line

$cities = array("New York", "London", "Sydney", "Paris", "Brisbane"); // <-- missing semi-colon

 

Oh my friggin god! What the hell? How embarrassing! Thanks for the help! Really appreciate it.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.