note 56178 deleted from function.strtok by googleguy

From: Date: Tue, 22 Oct 2013 14:53:50 +0000
Subject: note 56178 deleted from function.strtok by googleguy
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-197208@lists.php.net to get a copy of this message
Note Submitter: rawat dot arun at gmail dot com ---- I was trying to compare two strings of equal length using strtok. However using them at same time leads into erratic output. Therefore the output of each strok can first be stored in an array and then be used for comparison. Here is small code for it. <?php $string = "This is an XYZ example string"; $tok = strtok($string, ' '); while ($tok !== false) { $toks[] = $tok; $tok = strtok(' '); } $string_1= "This is an unknown example string"; $tok1= strtok($string_1, ' ');while ($tok1 !== false) { $toks1[] = $tok1;$tok1 = strtok(' '); } $ctr=0; while (each ($toks)) if ($toks[$ctr]==$toks1[$ctr]) {echo "W=$toks[$ctr]<br />"; echo "W1=$toks1[$ctr]<br />"; $ctr++; } else $ctr++; ?> Thanks, Arun

« previous php.notes (#197208) next »