Re: Manipulating text

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Quite right..


BUTTTTTTTT:

and I quote:

>> > $variable = "play_time";
>> >
>> > how may I remove "play_" from $variable and just have $variable equal
>> > to
>> > "time"?


To me, that is asking to strip or remove the string "play_" from the string "play_time"


Am I wrong? Especially when reinforced with "and just have the $variable equal to 'time'?"



Sorry, I wasn't aiming to create a problem or disorder, but I was merely stating the way I thought most effective to get the end result it seemed that at the time you wanted from that question. Sure an array is ONE possibility, while we're on the same track I could also convert the string to binary and let you manipulate it that way.. Hey same result, just different method.

Glad to know you've found a way to get around it anyway, thats what these lists are for..

;-)


Regards

---oOo--- Allowing users to execute CGI scripts in any directory should only be considered if: ... a.. You have no users, and nobody ever visits your server. ... Extracted Quote: Security Tips - Apache HTTP Server ---oOo--- ------oOo---------------oOo------ Julien Bonastre [The_RadiX] The-Spectrum Network CEO ABN: 64 235 749 494 julien@xxxxxxxxxxxxxxxx www.the-spectrum.org ------oOo---------------oOo------ ----- Original Message ----- From: "Ron Piggott (PHP)" <ron.php@xxxxxxxxxxxxxxxxxx>
To: "Julien Bonastre" <julien@xxxxxxxxxxxxxxxx>
Sent: Friday, December 09, 2005 8:43 PM
Subject: Re:  Manipulating text



There may some merit in an array for a response --- I didn't say what I
was going to do with this once I had my single word.  Ron

On Fri, 2005-12-09 at 18:33 +1000, Julien Bonastre wrote:
Alternatively you may again use a regex statement


[Aside]
Is it just me? Or does nobody know how to use or of the existence of Regular
Expressions??
Why does nobody suggest them???
I find them not only a God send, but more of a primitive form of God[or
Allah/Buddah/<insert deity here>]'s very first most useful creation ever. I
find water less important than that of Regular Expressions..

Ok so I have exaggerated as usual, but do you get my point??
blah!
[/Aside]

$str = "this_word";
$clean_str = preg_replace("/.*_([\w]+)$/i","$1",$str);

That would work as well...


Plus the advantage is that you don't return with an array, not that arrays
are all that bad, my first child will be named Arrarius..

Ok.. more bullcrap..

haha, nevertheless, depending on the situation, you may WANT to have an
array returned in which will simply be exploding, or spliting the elements
of the string seperated by the "_" underscore character in an array..

If you are simply wanting to strip any word before and including the
underscore character and return with a "clean" string, then my method is
great for that.

I just seem to have read your question and obviously intepreted it
differently than the others??



Let me know what you prefer.





---oOo--- Allowing users to execute CGI scripts in any directory should only
be considered if: ... a.. You have no users, and nobody ever visits your
server. ... Extracted Quote: Security Tips - Apache HTTP
Server ---oOo--- ------oOo---------------oOo------ Julien Bonastre
[The_RadiX] The-Spectrum Network CEO ABN: 64 235 749 494
julien@xxxxxxxxxxxxxxxx
www.the-spectrum.org ------oOo---------------oOo------ ----- Original Message ----- From: "Ron Piggott (PHP)" <ron.php@xxxxxxxxxxxxxxxxxx>
To: <amol@xxxxxxxxxx>; "PHP DB" <php-db@xxxxxxxxxxxxx>
Sent: Friday, December 09, 2005 2:13 PM
Subject: Re:  Manipulating text


> Thanks for telling me the 'explode' command.  Ron
>
> On Fri, 2005-12-09 at 08:07 +0530, Amol Hatwar wrote:
>> On Thu, 2005-12-08 at 21:25 -0500, Ron Piggott (PHP) wrote:
>> > If I have
>> >
>> > $variable = "play_time";
>> >
>> > how may I remove "play_" from $variable and just have $variable >> > equal
>> > to
>> > "time"?
>> >
>>
>> If you are hinting at '_' as a delimitter, you can use explode(). >> Learn
>> more about it here:
>> http://php.net/explode
>>
>> Regards,
>>
>> ah
>>
>
> -- > PHP Database Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>




--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [PHP Users]     [Postgresql Discussion]     [Kernel Newbies]     [Postgresql]     [Yosemite News]

  Powered by Linux