Archives Wild Code School
PHP

✏️ Exercise 3 - String manipulation

Quête 11 sur 14

Introduction

image

⚠️ Before starting this quest, you must have finished the following quests:
Quêtes liées

💪 Challenge

Exercice 1 : circle of life

Write your story about the circle of life, using the 6 variables below. You should use the concatenation operator.

php
$seedling = '🌱';
$caterpillar = '🐛';
$spider = '🕷️';
$frog = '🐸';
$owl = '🦉';
$fox = '🦊';

// write your story in this variable
$circleOfLife = '';

Exercice 2 : The king is dead, long live the king!

php
$king = 'Mufasa';
  • display only the first character of the $king name
  • display only the last character of the $king name
  • Change the name of the king, it is now 'Simba'.
  • display only the second character of the new $king name

Exercice 3 : anagrams

Using the variables below, find the anagram and concatenate characters in the correct order to display it.

Hint : of course, you should not directly write the answer, but get each character from the variable, reorder them and use concatenation operator.

php
$shinningAnagram = 'star';
// display anagram here 🐀🐀🐀 

$oldAnagram = 'raptor';
// display anagram here 🦜

🧐 Acceptance criteria

  • [ ] All the strings are correctly displayed
  • [ ] You have understand the concatenation operator
  • [ ] You know how to retrieve a particular character in a string