PHP Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me

The Shed is going Social! Join us on FaceBook and Twitter and chime in on the conversation.

Go Back   Dev Shed ForumsProgramming LanguagesPHP Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old June 22nd, 2000, 08:21 PM
baldwnad baldwnad is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: May 2000
Posts: 30 baldwnad User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 14
Send a message via ICQ to baldwnad
I am trying to parse out a string. Lets say the string is x length with spaces every so often. They spaces are random. I want to parse out every 50 characters, but if that 50th character isn't a space to lengthen what it is going to parse out until it reaches a space. After that do the loop until there is no more string left to parse.

--Any help is greatly appreciated since I have been driving myself insane over this! THANKS!

Reply With Quote
  #2  
Old June 22nd, 2000, 09:25 PM
updatelee updatelee is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jun 2000
Posts: 7 updatelee User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
$c = 0;
$pos = 0;
while ( $c < strlen($text) )
{
$c += 50;
for ($more = $c; $more < strlen($text) AND $text[$more] != ' '; $more++)
echo "$more <br>n";
$ntext[] = $more . '|' . substr($text, $pos, ($more - $pos));
$pos = $more;
$c = $more;
}

if (isset($ntext))
for ($count = 0; $count < count($ntext); $count++)
echo "$count $ntext[$count]<br>n";


$text is your initial string, $ntext[] if your exploded version.

Chris Lee

Reply With Quote
  #3  
Old June 22nd, 2000, 09:28 PM
updatelee updatelee is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jun 2000
Posts: 7 updatelee User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
oops dump the

echo "$more<br>n";

and replace with

{}

hehe, debug code.

Chris Lee

Reply With Quote
  #4  
Old June 22nd, 2000, 09:43 PM
baldwnad baldwnad is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: May 2000
Posts: 30 baldwnad User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 14
Send a message via ICQ to baldwnad
THANKS!!!! That helped emensly. I was just goofing up in a couple places but now I see what I did wrong! 1,000 thank yous!!! :-)

-Adam Baldwin

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming LanguagesPHP Development > String Parsing..ARGH!

Developer Shed Advertisers and Affiliates



Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 


Powered by: vBulletin Version 3.0.5
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.

© 2003-2013 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap