Welcome, Guest. Please login or register.
Did you miss your activation email?


Login with username, password and session length

News

Welcome to Yet Another Programming Community!

 
Pages: [1]   Go Down Print
Author Topic: Removing characters within 2 positions in a string?  (Read 219 times)
ReCreate
Full Member
***

Karma: +2/-24
Offline Offline

Posts: 161


GML/PHP/C++/VB6/Turing Programmer

recretae123@gmail.com
View Profile WWW
« on: November 19, 2009, 08:32:13 PM »

Well, I can't find a function for it, Is it possible?
What I want to do is to remove all the characters within 2 positions in a string.
Thanks
~ReCreate
Logged

TheMagicNumber
Full Member
***

Karma: +1/-25
Offline Offline

Posts: 123

What?


View Profile
« Reply #1 on: November 20, 2009, 06:12:43 AM »

Try using that XML parser you should already be using from before, you can turn it back into XML.
Logged

ReCreate
Full Member
***

Karma: +2/-24
Offline Offline

Posts: 161


GML/PHP/C++/VB6/Turing Programmer

recretae123@gmail.com
View Profile WWW
« Reply #2 on: November 20, 2009, 11:39:11 AM »

Cut the shit with that XML parser, It is not what I need.
I have a string that contains "123456789" and I want to remove the characters within the 2 positions: 3 and 6, So i should get "123789" in return.(assuming that 1 is for the first character)
Logged

TheMagicNumber
Full Member
***

Karma: +1/-25
Offline Offline

Posts: 123

What?


View Profile
« Reply #3 on: November 20, 2009, 03:01:36 PM »

You FAIL. Make a function to do it. It's not that hard (no, I will NOT do it for you).

Seriously, TRY.

By the way, sorry, I misread. I thought you meant XML again. 8D
« Last Edit: November 20, 2009, 10:49:13 PM by TheMagicNumber » Logged

tdub311
Newbie
*

Karma: +0/-0
Offline Offline

Posts: 3


View Profile
« Reply #4 on: November 21, 2009, 03:49:33 PM »

Made a quick function. I think this should do the job.

function newStr_replace($string$start$end$replace) {
  
$number $end $start 1;
  
$string substr_replace($string$replace$start$number);
  return 
$string;
}

This:
echo newStr_replace("123456789"25"");
Returns:
12789 (it starts at pos 2 (3 in this case b/c you start at 0), and ends (also deletes) at pos 5 (6 in this case))

Hope thats what you wanted
Logged
ReCreate
Full Member
***

Karma: +2/-24
Offline Offline

Posts: 161


GML/PHP/C++/VB6/Turing Programmer

recretae123@gmail.com
View Profile WWW
« Reply #5 on: November 22, 2009, 07:58:04 PM »

Thanks, So you say with that function the index is 2?
You FAIL. Make a function to do it. It's not that hard (no, I will NOT do it for you).

Seriously, TRY.
I would have if you told me that there was no function for it. >_<
Logged

TheMagicNumber
Full Member
***

Karma: +1/-25
Offline Offline

Posts: 123

What?


View Profile
« Reply #6 on: November 23, 2009, 07:17:31 AM »

Lolcreate.

If you can't find it on php.net, I'm pretty sure it doesn't exist.
Logged

tdub311
Newbie
*

Karma: +0/-0
Offline Offline

Posts: 3


View Profile
« Reply #7 on: November 24, 2009, 03:16:34 PM »

Thanks, So you say with that function the index is 2?
Are you talking about the $start value?
Logged
Pages: [1]   Go Up Print
 
Jump to:  

 
     
Powered by MySQL Powered by PHP Powered by SMF 1.1.10 | SMF © 2006-2009, Simple Machines LLC
Theme by Roach
Valid XHTML 1.0! Valid CSS!