Current location: Hot Scripts Forums » Programming Languages » PHP » substr() question


substr() question

Reply
  #11 (permalink)  
Old 07-06-09, 05:41 AM
Nico's Avatar
Nico Nico is offline
Community Leader
 
Join Date: Sep 2005
Location: Spain
Posts: 8,075
Thanks: 11
Thanked 88 Times in 83 Posts
You may be given an unexpected result because you're capturing the offsets. If you leave out the OFFSET_CAPTURE flag, you should get the same kind of array you get when using explode().
Reply With Quote
  #12 (permalink)  
Old 07-06-09, 06:08 AM
jonnekke jonnekke is offline
Code Guru
 
Join Date: Oct 2005
Location: holland!
Posts: 706
Thanks: 0
Thanked 0 Times in 0 Posts
this is the end result of my script that does the job completely for me:

PHP Code:

$item_linkerkant_verhaal1 preg_split("/\.|\?|\!/"$item_linkerkant_verhaal, -1PREG_SPLIT_OFFSET_CAPTURE);

$aantal count($item_linkerkant_verhaal1);

$item_linkerkant_verhaal_intro "";

for(
$i=0$i$aantal-1$i++){
    
$i2$i-1;    
    
    
$waarvanaf = ($item_linkerkant_verhaal1[$i2][1])-1;
    
$item_linkerkant_verhaal_intro_end substr($item_linkerkant_verhaal$waarvanaf1);
    
    
$item_linkerkant_verhaal_intro $item_linkerkant_verhaal_intro.$item_linkerkant_verhaal1[$i][0].$item_linkerkant_verhaal_intro_end;

sorry for the variable names in dutch..

_j
Reply With Quote
  #13 (permalink)  
Old 07-07-09, 09:24 AM
Nico's Avatar
Nico Nico is offline
Community Leader
 
Join Date: Sep 2005
Location: Spain
Posts: 8,075
Thanks: 11
Thanked 88 Times in 83 Posts
Do what I said in my previous post.
Reply With Quote
  #14 (permalink)  
Old 07-09-09, 07:02 AM
jonnekke jonnekke is offline
Code Guru
 
Join Date: Oct 2005
Location: holland!
Posts: 706
Thanks: 0
Thanked 0 Times in 0 Posts
do you mean do this aswell?.

Or the script is okej now because I did what you suggested?
Reply With Quote
  #15 (permalink)  
Old 07-09-09, 07:12 AM
Nico's Avatar
Nico Nico is offline
Community Leader
 
Join Date: Sep 2005
Location: Spain
Posts: 8,075
Thanks: 11
Thanked 88 Times in 83 Posts
You still didn't do what I suggested:
Quote:
Originally Posted by Nico View Post
If you leave out the OFFSET_CAPTURE flag, you should get the same kind of array you get when using explode().
Reply With Quote
Reply

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

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

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Newbie member, (semi)novice developer has a question WorkyMcWorkerson Script Requests 2 11-26-08 01:28 PM
Injecting a string into an If Statement ? nova912 PHP 4 07-21-06 02:04 PM
Posting a question / answer on site markcody PHP 2 11-23-04 01:58 PM
[PHP] Array question UmiSal Script Requests 1 04-05-04 01:52 PM
question and answer software jaydifox C/C++ 0 02-21-04 09:26 AM


All times are GMT -5. The time now is 08:40 AM.
vBulletin® Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.