PHP Dividing String Into Tokens With Strtok() – String Function

<?php
<html>
<head>
<title>Dividing a string into tokens with strtok()</title>
</head>
<body>
<div>
<?php
$test = "php?id=353&sec=44&user=harry&context=php";$delims = "?&";
$word = strtok( $test, $delims );
while ( is_string( $word ) ) {
 if ( $word ) {
   print "$word<br/>";
 }
 $word = strtok( $delims );
}
?>
</div>
</body>
</html>

Enjoyed this post? Share it!

 

Leave a comment

Your email address will not be published.