Hi, I need todo 3 functions todo the following to some text:
1. remove all occurances of <br />
2. changing first letter of each line to a capital
3. and first letter of each word to a capital
Cheers, I'll let you know how it goes as soon as I've tested it (at uni at mo and can't test). It's quite important that the function for 2 and 3 are different because I need to use them in different situations. I think the one you posted above is the solution to the third one. Thanx
That's abit mean, it's not for a uni project because we don't get the pleasure of using php for a project which I'd probably breeze. It's for a website
sorry, I wasn't trying to be mean I was just checking!
to replace the first letter of the line with upper case just change the word boundary characters in the regular expression to the newline character... i.e.
Hey, I checked your functions by running the script at the bottom and the outputted text was blank shown below. Note I corrected a parse error in your solution:
<?
$string = "Am I correct to defend the fist that holds this pen?<br />
It's ink that lies,<br />
the pen, the page, the paper.<br />
I live, I learn.<br />
You will always take what i have earned.<br />
And so aid my end while I believe I'm winning.";
$string2 = "Good to know that if I had attention";
You might need to wrap your regexes in delimiters i.e. change them to:
$string2 = preg_replace("/\n(.)/e", strtoupper('\\1'),$string2);
$string = preg_replace("/\b(.)/e", strtoupper('\\1'),$string);
Nope still didn't work. The errors I got are below:
$string2 = preg_replace("/\n(.)/e", strtoupper('\\1'),$string2); // This just didn't change the string
$string = preg_replace("/\b(.)/e", strtoupper('\\1'),$string); // Returned an error
Hi, another thing I really need help with is how to cut a string to a certain length. I found the function mb_strcut from php.net/manual but I need to install another module to get this working. If someone could tell me an alternative I'd be greatful. Thanx
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.