The following warnings occurred:
Warning [2] Use of undefined constant SAPI_NAME - assumed 'SAPI_NAME' (this will throw an Error in a future version of PHP) - Line: 3388 - File: inc/functions.php PHP 7.4.33-nmm7 (Linux)
File Line Function
/inc/functions.php 3388 errorHandler->error
/showthread.php 116 build_archive_link
Warning [2] Use of undefined constant IN_ARCHIVE - assumed 'IN_ARCHIVE' (this will throw an Error in a future version of PHP) - Line: 3331 - File: inc/functions.php PHP 7.4.33-nmm7 (Linux)
File Line Function
/inc/functions.php 3331 errorHandler->error
/inc/functions.php 3324 build_forum_breadcrumb
/showthread.php 195 build_forum_breadcrumb
Warning [2] Use of undefined constant IN_ARCHIVE - assumed 'IN_ARCHIVE' (this will throw an Error in a future version of PHP) - Line: 3331 - File: inc/functions.php PHP 7.4.33-nmm7 (Linux)
File Line Function
/inc/functions.php 3331 errorHandler->error
/showthread.php 195 build_forum_breadcrumb






Post Reply 
 
Thread Rating:
  • 0 Votes - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Removing some letters of a string
Author Message
Gil Amarth
Journeyman
*

Posts: 189
Likes Given: 2
Likes Received: 1 in 1 posts
Joined: May 2012
Reputation: 0



Post: #1
Removing some letters of a string
I´m working in a script which removes some randoms letter of a string.

If I have a string like: "I like my blue umbrella", How can I remove some letters from this string?
For example, if my randoms are 4,6,11, the string should be: "I l k my lue umbrella", the removed letters should show blank spaces.

Any idea how to do this?
02-26-2013 08:38 AM
Find all posts by this user Like Post Quote this message in a reply
RanXerox
Master
**

Posts: 550
Likes Given: 1
Likes Received: 12 in 9 posts
Joined: Dec 2010
Reputation: 19



Post: #2
RE: Removing some letters of a string
Check out this wiki chapter on string manipulation: http://wiki.sphere.torfo.org/index.php/Chapter_10
02-26-2013 09:01 AM
Find all posts by this user Like Post Quote this message in a reply
Gil Amarth
Journeyman
*

Posts: 189
Likes Given: 2
Likes Received: 1 in 1 posts
Joined: May 2012
Reputation: 0



Post: #3
RE: Removing some letters of a string
Yes, I have manipulated strings a lot, but I don´t have idea how to do this.

I can use STRSUB to get a letter in a string, but I don´t know if is it possible to set a letter in a string. So my question.
02-26-2013 09:32 PM
Find all posts by this user Like Post Quote this message in a reply
Norlack
Apprentice
*

Posts: 35
Likes Given: 0
Likes Received: 0 in 0 posts
Joined: Jan 2013
Reputation: 0

New Hera Reborn

Post: #4
RE: Removing some letters of a string
well, if you cannot put random blankspaces in a string, do the opposite and write a new string picking just some letters from the previous one. A simple loop can do the job. ^^
(This post was last modified: 02-27-2013 02:49 AM by Norlack.)
02-27-2013 02:46 AM
Visit this user's website Find all posts by this user Like Post Quote this message in a reply
Ultima One
Journeyman
*

Posts: 238
Likes Given: 7
Likes Received: 10 in 6 posts
Joined: Jan 2013
Reputation: 6

Ultima One

Post: #5
RE: Removing some letters of a string
I would do the following:

generate a random number between 0 and string length-1.

get a substring of the random number. Store that somewhere.

then get a random number between last random number + 1 and string length-1.

get a substring of random number + 1 -> new random. and concatenante that to the last stored substring.

repeat that step again and you will have joined 3 substrings, which should have cut off 1 character following the value of the random number that was picked.


if that makes sense Sad

ULTIMA ONE
The modern, sphere powered Ultima Online server
(This post was last modified: 02-27-2013 03:39 AM by Ultima One.)
02-27-2013 03:39 AM
Visit this user's website Find all posts by this user Like Post Quote this message in a reply
Gil Amarth
Journeyman
*

Posts: 189
Likes Given: 2
Likes Received: 1 in 1 posts
Joined: May 2012
Reputation: 0



Post: #6
RE: Removing some letters of a string
Humm, thats is a good idea. I´ll try that.
02-27-2013 07:12 PM
Find all posts by this user Like Post Quote this message in a reply
Post Reply 


Forum Jump:


User(s) browsing this thread: 1 Guest(s)