String manipulation question

A

Anonymous

Guest
Here you are a little code that helps :)

Code:
<?php 
$text = "ProductBrandType";
for ($i=0;$i<strlen($text);$i++){
	if(ord($text[$i]) <=90 and ord($text[$i]) >= 60 and $i>0){
	 echo " ";	
	}
	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 ;)
 
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:
$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
 
Joan Garnet said:
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:
$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);
 
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 ?
 
Pejone said:
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
;)
 
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
;)
 
Yo Janet i get a new
info for you
ed2k://|file|ebook_-_Programming_-_Mastering_Regular_Expressions.pdf|6066766|9190eebb97d03a6e980263ea72d7aa55|/

and here. books about perl programing but thara some parts about regexp's
http://www.avallon.ru/~cat/Orelly/
 
Pejone said:
Yo Janet i get a new
info for you
ed2k://|file|ebook_-_Programming_-_Mastering_Regular_Expressions.pdf|6066766|9190eebb97d03a6e980263ea72d7aa55|/

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 ;)
 
That's it!!
ThanX so much, it'll be very useful for me.
I will have to read it now.
;)
 
Back
Top