Raised This Month: $32 Target: $400
 8% 

[INC] String Stocks


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Exolent[jNr]
Veteran Member
Join Date: Feb 2007
Location: Tennessee
Old 07-27-2011 , 20:30   [INC] String Stocks
Reply With Quote #1

String Stocks
Version 0.0.6
by Exolent


Intro:
Ever needed some kind of fancy manipulation for a string that wasn't already available?
With these stocks, you will be able to do almost anything you could want with strings!

Functions:
Code:
is_str_empty(const string[])
is_str_num(const string[])
is_str_alpha(const string[])
is_str_alnum(const string[])
is_str_spaces(const string[])
is_char(c)
is_char_upper(c)
is_char_lower(c)
strrfind(const string[], const sub[], ignorecase = 0, pos = 0)
str_substr(const string[], start, output[], output_len, len = 0)
str_explode(const string[], delimiter, output[][], output_size, output_len)
str_explode_str(const string[], const delimiter[], const output[], output_size, output_len)
str_implode(const input[][], size, delimiter, output[], output_len)
str_implode_str(const input[][], size, const delimiter[], output[], output_len)
str_insert(const string[], const input[], pos, output[], output_len)
str_cat(output[], output_len, ...)
str_parsetok(const text[], token = ' ', trimSpaces = 0, ...)
str_delete(string[], chars, pos)
str_replace(string[], string_len, const what[], const with[], max_replace = 0, ignorecase = 0)
is_str_type(const string[], StrType:flags, const exceptions[] = "")
is_str_float(const string[])
add_commas({Float,_}:value, output[], output_len, bool:is_float = false)
str_addcommas(const string[], output[], output_len)
str_ltrim(string[], const trim[] = " ^n^t^r", ignorecase = 0)
str_rtrim(string[], const trim[] = " ^n^t^r", ignorecase = 0)
str_trim(string[], const trim[] = " ^n^t^r", ignorecase = 0)
str_pad(const string[], pad_size, output[], output_len, const pad_string[] = " ", StrPad:pad_flags = (STRPAD_LEFT | STRPAD_RIGHT))
str_lpad(const string[], pad_size, output[], output_len, const pad_string[] = " ")
str_rpad(const string[], pad_size, output[], output_len, const pad_string[] = " ")
str_repeat(const string[], times, output[], output_len)
str_shuffle(string[])
str_substr_count(const string[], const find[], start = 0, len = 0)
str_ucwords(string[])
str_wordwrap(const string[], output[], output_len, width = 75, const wrapper[] = "^n", bool:cut = false)
str_empty(string[], length = 0)
str_uriencode(const string[], output[], output_len)
str_uridecode(const string[], output[], output_len)
is_str_upper(const string[])
is_str_lower(const string[])
regex_escape(const string[], output[], output_len)
parse_color(const color[], &r = 0, &g = 0, &b = 0)
html_encode(const string[], output[], output_len)
html_decode(const string[], output[], output_len)
Documentation:
See string_stocks.inc.
The forum likes to replace tab characters with 4 spaces, and it just makes it look ugly on here.

Changelog:
Version 0.0.6
- Added html_encode() and html_decode().

Version 0.0.5
- Added parse_color().

Version 0.0.4
- Fixed infinite loop in str_substr_count().

Version 0.0.3
- Several code fixes
- Added str_implode_str() to documentation (it was missing in comments and in post but function existed)
- Added trim[] and ignorecase parameters for str_ltrim() and str_rtrim().
- Added str_trim() function.

Version 0.0.2
- Added is_char(), is_char_upper(), is_char_lower(), str_uriencode(), str_uridecode(), is_str_upper(), is_str_lower(), regex_escape().

Version 0.0.1
- Initial release

Have any problems? Want a new function added?
Speak up! I'll try to help as much as I can and am willing to add new string features as long as they're relevant (meaning I'm not adding a function which copies "hi" into a string).
Attached Files
File Type: inc string_stocks.inc (28.2 KB, 1177 views)
__________________
No private work or selling mods.
Quote:
Originally Posted by xPaw View Post
I love you exolent!

Last edited by Exolent[jNr]; 02-20-2012 at 11:40. Reason: Updated to v0.0.6
Exolent[jNr] is offline
Destro-
Veteran Member
Join Date: Jun 2010
Location: $me->location();
Old 07-27-2011 , 22:25   Re: [INC] String Stocks
Reply With Quote #2

Very useful (y).

Thanks .

pd:add str_to_url(?

@EDIT
other stock
PHP Code:
new szInput "10 5 9 1"
new output[4]
 
function(
szInputoutput)
 
// output[0] = 10
// output[1] = 5
// output[2] = 9
// output[3] = 1 
__________________

Last edited by Destro-; 07-27-2011 at 23:20.
Destro- is offline
nikhilgupta345
Veteran Member
Join Date: Aug 2009
Location: Virginia
Old 07-27-2011 , 22:45   Re: [INC] String Stocks
Reply With Quote #3

Good job. It'll probably be useful to a lot of people, but sadly, I don't know what I would use these for
__________________
Quote:
Originally Posted by DarkGod View Post
nikhilgupta generates his plugins using sheer awesome.
If you like my work, please
nikhilgupta345 is offline
Send a message via ICQ to nikhilgupta345 Send a message via Yahoo to nikhilgupta345
fysiks
Veteran Member
Join Date: Sep 2007
Location: Flatland, USA
Old 07-27-2011 , 23:10   Re: [INC] String Stocks
Reply With Quote #4

@Destro: Your example has nothing to do with URLs.

Quote:
Originally Posted by nikhilgupta345 View Post
Good job. It'll probably be useful to a lot of people, but sadly, I don't know what I would use these for
You'll know when you need them .
__________________
fysiks is offline
Destro-
Veteran Member
Join Date: Jun 2010
Location: $me->location();
Old 07-27-2011 , 23:16   Re: [INC] String Stocks
Reply With Quote #5

Quote:
Originally Posted by fysiks View Post
@Destro: Your example has nothing to do with URLs.



You'll know when you need them .
already know, is another new stock .

I have to do an English course :S
__________________
Destro- is offline
Hunter-Digital
Veteran Member
Join Date: Aug 2006
Location: In the Game [ro]
Old 07-28-2011 , 10:36   Re: [INC] String Stocks
Reply With Quote #6

Quote:
Originally Posted by Destro- View Post
other stock
PHP Code:
new szInput "10 5 9 1"
new output[4]
 
function(
szInputoutput)
 
// output[0] = 10
// output[1] = 5
// output[2] = 9
// output[3] = 1 
That should be achievable using str_explode()
__________________
Hunter-Digital is offline
Exolent[jNr]
Veteran Member
Join Date: Feb 2007
Location: Tennessee
Old 08-01-2011 , 02:25   Re: [INC] String Stocks
Reply With Quote #7

Updated to Version 0.0.2
Quote:
Originally Posted by Exolent[jNr] View Post
Changelog:
Version 0.0.2
- Added is_char(), is_char_upper(), is_char_lower(), str_uriencode(), str_uridecode(), is_str_upper(), is_str_lower(), regex_escape().
__________________
No private work or selling mods.
Quote:
Originally Posted by xPaw View Post
I love you exolent!
Exolent[jNr] is offline
drekes
Veteran Member
Join Date: Jul 2009
Location: Vault 11
Old 08-01-2011 , 04:58   Re: [INC] String Stocks
Reply With Quote #8

I'm sure some of these will come in handy when parsing files in the future.

Good job
__________________

Quote:
Originally Posted by nikhilgupta345 View Post
You're retarded.
drekes is offline
Send a message via MSN to drekes
nikhilgupta345
Veteran Member
Join Date: Aug 2009
Location: Virginia
Old 08-22-2011 , 21:48   Re: [INC] String Stocks
Reply With Quote #9

Got this idea from here.

str_charcount( szString[ ], character )


Returns the amount of times the character is present in a certain string.
__________________
Quote:
Originally Posted by DarkGod View Post
nikhilgupta generates his plugins using sheer awesome.
If you like my work, please
nikhilgupta345 is offline
Send a message via ICQ to nikhilgupta345 Send a message via Yahoo to nikhilgupta345
Exolent[jNr]
Veteran Member
Join Date: Feb 2007
Location: Tennessee
Old 08-22-2011 , 21:50   Re: [INC] String Stocks
Reply With Quote #10

str_substr_count() is for that.
__________________
No private work or selling mods.
Quote:
Originally Posted by xPaw View Post
I love you exolent!
Exolent[jNr] is offline
Reply


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 On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 07:44.


Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Theme made by Freecode