Reputation: 439
What will be the output of following PHP code:
<?php
echo strtok("Hello world!","kHlleo");
?>
answer is w
can any one explain how it works to output w ? i know strtok tokenise the string, but not understanding this particular question.
Upvotes: 0
Views: 84
Reputation: 101
It basically returns a list with letters that are not filtered. You filter the letters "kHlleo", out of "Hello world!", leaving w, r and d!.
$tok = strtok("Hello world!", "kHlleo");
while ($tok !== false) {
echo "Word=$tok<br />";
$tok = strtok("kHlleo");
}
Upvotes: 1