On Sat, 2006-09-09 at 13:14 -0500, Wade Smart wrote:
> 09092006 1312 GMT-6
> 
> That is what Im talking about, except for one thing. 
> There are usually more than one section to copy. So, when I used
> strpos() to find the first section to be copied, I might still have two
> to 15 other sections to find. 

Just use the offset value within strpos()
http://us3.php.net/manual/en/function.strpos.php

Modified steps below:
1) Read the file into a variable, like with file_get_contents()
2) Find the numeric position of the first string, maybe with strpos()
3) Find the numeric position of the last string, again, with strpos()
4) use substr() to grab the string in between
    substr (filestring, firstpos, length ) where length=lastpos-firstpos
    http://us2.php.net/manual/en/function.substr.php
5) Write string returned in #4 to a file
6) Then use strpos() with the offset, to only search the remaining part
of the file
7) repeat steps 2-6 until strpos() returns false.

So for a short example, to better explain what I mean:

$beg indicates the beginning string and $end indicates the ending string

1) Use file_get_contents() to read file into $string
2) Do strpos($string,$beg) to get the first occurrence of $beg, =
$begpos.
3) Do strpos($string,$end) to get the first occurrence of $end, =
$endpos.
4) Do substr($string,$begpos,$begpos-$endpos) to get the desired string
5) Write that to file
6) Now do strpos($string,$beg,$endpos) to get the next occurrence of
$beg, = $begpos (a new value)
7) Do strpos($string,$end,$endpos) to get the next occurrence of $end, =
$endpos (another new value).
8) Do substr($string,$begpos,$begpos-$endpos) using the new $begpos and
the new $endpos to get the desired string
9) Write that to file

Continue until strpos() returns a false value.


If that method doesn't work, then you could try using strstr* (or
stristr**) to cut the string size down to only include the portion of
the file that you have not yet searched.

* http://us3.php.net/manual/en/function.strstr.php
** http://us3.php.net/manual/en/function.stristr.php

HTH,
--
Doug

Registered Linux User #285548 (http://counter.li.org)
----------------------------------------
Random Thought:
War is an equal opportunity destroyer.



Community email addresses:
  Post message: php-list@yahoogroups.com
  Subscribe:    [EMAIL PROTECTED]
  Unsubscribe:  [EMAIL PROTECTED]
  List owner:   [EMAIL PROTECTED]

Shortcut URL to this page:
  http://groups.yahoo.com/group/php-list 
Yahoo! Groups Links

<*> To visit your group on the web, go to:
    http://groups.yahoo.com/group/php-list/

<*> Your email settings:
    Individual Email | Traditional

<*> To change settings online go to:
    http://groups.yahoo.com/group/php-list/join
    (Yahoo! ID required)

<*> To change settings via email:
    mailto:[EMAIL PROTECTED] 
    mailto:[EMAIL PROTECTED]

<*> To unsubscribe from this group, send an email to:
    [EMAIL PROTECTED]

<*> Your use of Yahoo! Groups is subject to:
    http://docs.yahoo.com/info/terms/
 



Reply via email to