note 40066 added to function.strpos

From: Date: Fri, 20 Feb 2004 15:40:49 +0000
Subject: note 40066 added to function.strpos
Groups: php.notes 
Request: Send a blank email to php-notes+get-65449@lists.php.net to get a copy of this message
<?php $text="i wanted to write a parser that gets the value of searchme[15] and also the value of searchmealso(166). it can be modified to return the amount of found strings or something else...i hope you find it useful, even if the function returns nothing at the moment. "; testreport($text); function testreport($text) { for($i=0;$i<strlen($text);$i++) { $s=1; $maxsize=5; $searchedfor[1]="searchme"; $searchedfor[2]="searchmealso"; $index_on_for[1]="["; $index_on_for[2]="("; $index_off_for[1]="]"; $index_off_for[2]=")"; while($searchedfor[$s]!="") { $word=""; $size=strlen($searchedfor[$s]); for($i_up=$i;$i_up<$i+$size;$i_up++) { $word.=$text{$i_up}; } if($word==$searchedfor[$s]) { echo "Jeehaaw! Found a $word!<br />"; $v_up=$i_up; $index_found="false"; $value=""; while($index_found=="false") { if($text{$v_up}==$index_on_for[$s])$v_up++; if($text{$v_up}!=$index_off_for[$s])$value.=$text{$v_up}; if($text{$v_up}==$index_off_for[$s] || $v_up>$i_up+$maxsize)$index_found="true"; $v_up++; } echo "Value of $word: $value!<br />"; } $s++; } } } ?> ---- Manual Page -- http://www.php.net/manual/en/function.strpos.php Edit -- http://master.php.net/manage/user-notes.php?action=edit+40066 Delete -- http://master.php.net/manage/user-notes.php?action=delete+40066&report=yes Reject -- http://master.php.net/manage/user-notes.php?action=reject+40066&report=yes Search -- http://master.php.net/manage/user-notes.php

« previous php.notes (#65449) next »