How to use strtok in PHP

In this article I will explain how strtok function used in PHP.
  • 1944

strtok() Function

This function splits a string into smaller strings.

Syntax

strtok(string,split)

 

 Parameter  Description
 string  Required. Specifies the string to split
 split  Required. Specifies one or more split characters

Example

<html>
<body>
<?php
$string = "Hello Satya. Today is Sunday.";
$token = strtok($string, " ");

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

Output

strtok-php.jpg

You may also want to read these related articles Click here

Ask Your Question 

Got a programming related question? You may want to post your question here

Programming Answers here

Categories

More Articles

© 2019 DotNetHeaven. All rights reserved.