Board index   FAQ   Search  
Register  Login
Board index php forum :: php coding PHP coding => General

String manipulation question

Ask about general coding issues or problems here.

Moderators: macek, egami, gesf

Postby Joan Garnet » Mon Nov 25, 2002 4:02 pm

Here you are a little code that helps :)

Code: Select all
<?php
$text = "ProductBrandType";
for ($i=0;$i<strlen($text);$i++){
   if(ord($text[$i]) <=90 and ord($text[$i]) >= 60 and $i>0){
    echo "&nbsp;";   
   }
   echo $text[$i];
}
?>


ord gets the ascii code of each letter from the string scanned by for, which is executed while $i value is less than the total size of the string $text.
If the ascii code is between 90 and 60 (the ascii code range for all uppercase letters) it prints an HTML space in the returnerd HTML code from the server to the user browser.

I hope it helped ;)
User avatar
Joan Garnet
Moderator
Moderator
 
Posts: 387
Joined: Sat Aug 03, 2002 2:56 am
Location: Mars

Postby Oleg Butuzov » Mon Nov 25, 2002 8:40 pm

$string = "MamaMylaRamu";
$string=preg_replace("/([A-Z])/"," \\1",$string);
Oleg Butuzov
Last Samuray
Last Samuray
 
Posts: 831
Joined: Sun Jun 02, 2002 3:09 am

Postby Joan Garnet » Tue Nov 26, 2002 7:38 am

mmm,
I was sure that there was a php function...
Can you explain the way it works??
For example, the common sample in all php manuals, which I tried to understand so many times before but finally getting bored :) -->

Code: Select all
$patterns = array ("/(19|20)(\d{2})-(\d{1,2})-(\d{1,2})/",
                   "/^\s*{(\w+)}\s*=/");
$replace = array ("\\3/\\4/\\1\\2", "$\\1 =");
print preg_replace ($patterns, $replace, "{startDate} = 1999-5-27");

It makes no sense for me... 8O
User avatar
Joan Garnet
Moderator
Moderator
 
Posts: 387
Joined: Sat Aug 03, 2002 2:56 am
Location: Mars

Postby mjr » Tue Nov 26, 2002 9:01 am

Joan Garnet wrote:mmm,
I was sure that there was a php function...
Can you explain the way it works??
For example, the common sample in all php manuals, which I tried to understand so many times before but finally getting bored :) -->

Code: Select all
$patterns = array ("/(19|20)(\d{2})-(\d{1,2})-(\d{1,2})/",
                   "/^\s*{(\w+)}\s*=/");
$replace = array ("\\3/\\4/\\1\\2", "$\\1 =");
print preg_replace ($patterns, $replace, "{startDate} = 1999-5-27");

It makes no sense for me... 8O


$s=preg_replace('/([A-Z])/',' \\1',$s);
mjr
New php-forum User
New php-forum User
 
Posts: 18
Joined: Fri Sep 27, 2002 6:35 am

Postby Oleg Butuzov » Tue Nov 26, 2002 9:55 am

ok.
i will ask at the livejournak comuniti ru_php about some english documentation about regexp's
i will give you or via email or here links ? is at ok for you ? :D

2mrj
so what ?
Oleg Butuzov
Last Samuray
Last Samuray
 
Posts: 831
Joined: Sun Jun 02, 2002 3:09 am

Postby Joan Garnet » Tue Nov 26, 2002 5:46 pm

Pejone wrote:ok.
i will ask at the livejournak comuniti ru_php about some english documentation about regexp's
i will give you or via email or here links ? is at ok for you ? :D

2mrj
so what ?


Wonderful !
:)
I'm waiting
;)
User avatar
Joan Garnet
Moderator
Moderator
 
Posts: 387
Joined: Sat Aug 03, 2002 2:56 am
Location: Mars

Postby Oleg Butuzov » Thu Nov 28, 2002 4:21 am

Thay do not give complit answer but somethig i have...
some perl regular expresions
Something here
Book that I recoment

I am sory but nothing else i did not have any more links :(

thare is some decription in php-manual but I hate it , because it is very hard to understand =(
Oleg Butuzov
Last Samuray
Last Samuray
 
Posts: 831
Joined: Sun Jun 02, 2002 3:09 am

Postby Joan Garnet » Thu Nov 28, 2002 9:04 am

Well,
I checked those links :)
I have an idea about what it does but, as the one who posted in that forum:
I can't memorize all the crap...I need to
test it to see what's really going on

:)

Very useful!
ThanX
;)
User avatar
Joan Garnet
Moderator
Moderator
 
Posts: 387
Joined: Sat Aug 03, 2002 2:56 am
Location: Mars

Postby Oleg Butuzov » Wed Dec 18, 2002 2:28 am

Yo Janet i get a new
info for you
ed2k://|file|ebook_-_Programming_-_Mast ... 72d7aa55|/

and here. books about perl programing but thara some parts about regexp's
http://www.avallon.ru/~cat/Orelly/
Oleg Butuzov
Last Samuray
Last Samuray
 
Posts: 831
Joined: Sun Jun 02, 2002 3:09 am

Postby Joan Garnet » Wed Dec 18, 2002 5:43 am

Pejone wrote:Yo Janet i get a new
info for you
ed2k://|file|ebook_-_Programming_-_Mast ... 72d7aa55|/

and here. books about perl programing but thara some parts about regexp's
http://www.avallon.ru/~cat/Orelly/


I don't understand the first one...
ed2k://|file|ebook_-_Programming_-_Mastering_Regular_Expressions.pdf|6066766|9190eebb97d03a6e980263ea72d7aa55|/

Sorry... :oops:
Can you tell me what is all about, please??

ThanX ;)
User avatar
Joan Garnet
Moderator
Moderator
 
Posts: 387
Joined: Sat Aug 03, 2002 2:56 am
Location: Mars

Postby Oleg Butuzov » Wed Dec 18, 2002 5:56 am

this is a link in program that called eDonkey or something =)
Oleg Butuzov
Last Samuray
Last Samuray
 
Posts: 831
Joined: Sun Jun 02, 2002 3:09 am

Postby Joan Garnet » Thu Dec 19, 2002 8:21 am

That's it!!
ThanX so much, it'll be very useful for me.
I will have to read it now.
;)
User avatar
Joan Garnet
Moderator
Moderator
 
Posts: 387
Joined: Sat Aug 03, 2002 2:56 am
Location: Mars

Postby Oleg Butuzov » Fri Dec 20, 2002 3:09 am

you wellcome =)
nice to see you here =)
Oleg Butuzov
Last Samuray
Last Samuray
 
Posts: 831
Joined: Sun Jun 02, 2002 3:09 am


Return to PHP coding => General

Who is online

Users browsing this forum: No registered users and 2 guests

Sponsored by Sitebuilder Web hosting and Traduzioni Italiano Rumeno and antispam for cPanel.

cron