/ / fonction strtok php ne fonctionne pas - php, strtok

la fonction strtok php ne fonctionne pas - php, strtok

J'ai le fichier suivant, enregistré au format .php:

<head>
<title>String Manipulation</title>
<meta charset = "utf-8">
</head>

<body>
<?php
$words = "Hello how are you";

$token = strtok($feedback, " ");
echo $token."<br />";

while ($token!="")
{
$token = strtok(" ");
echo $token."<br />";
};
?>
</body>
</html>

Je lis un livre sur php et ils ont ceciexemple et prétendent qu'il devrait imprimer chaque "jeton" (Dans ce cas, je pense que ce serait chaque mot?) sur une nouvelle ligne, mais quand je lance ce code rien ne se passe. Qu'est-ce que je fais incorrectement? PS: Je lance ceci avec MAMP si cela compte

Réponses:

0 pour la réponse № 1

Ce code devrait être:

<head>
<title>String Manipulation</title>
<meta charset = "utf-8">
</head>

<body>
<?php
$words = "Hello how are you";

$token = strtok($words, " ");
echo $token."<br />";

while ($token!="")
{
$token = strtok(" ");
echo $token."<br />";
};
?>
</body>
</html>

0 pour la réponse № 2
<?php
$words = "Hello how are you";
// Change $feedback to $words
$token = strtok($words, " ");
echo $token."<br />";

while ($token!=""){
$token = strtok(" ");
echo $token."<br />";
}
?>