Play with string: String conversion in PHP

Let’s two string

$s=”convert upper case to lower case, lower case to upper case and more!”;

$p=”Convert Case – Convert upper case to lower case, lower case to upper case and more! AccIdentALly left the caPs Lock on and typed something, but can’t be bothered to start again and retype it all?
Simply follow these following easy steps to COnvert your text to exactly how you want it. So, lEt’s try!!”;

And then,

echo strtolower($p);
Output:-
convert case – convert upper case to lower case, lower case to upper case and more! accidentally left the caps lock on and typed something, but can’t be bothered to start again and retype it all? simply follow these following easy steps to convert your text to exactly how you want it. so, let’s try!!

——————————————————-

echo strtoupper($p);
Output:-

CONVERT CASE – CONVERT UPPER CASE TO LOWER CASE, LOWER CASE TO UPPER CASE AND MORE! ACCIDENTALLY LEFT THE CAPS LOCK ON AND TYPED SOMETHING, BUT CAN’T BE BOTHERED TO START AGAIN AND RETYPE IT ALL? SIMPLY FOLLOW THESE FOLLOWING EASY STEPS TO CONVERT YOUR TEXT TO EXACTLY HOW YOU WANT IT. SO, LET’S TRY!!

——————————————————————-
echo ucfirst($s);
Output:-

Convert upper case to lower case, lower case to upper case and more!

————————————————————————–
echo ucwords($s);

Output:-

Convert Upper Case To Lower Case, Lower Case To Upper Case And More!

————————————————————————–
echo strtosentencecase($tp);

Output:-

Convert case – convert upper case to lower case, lower case to upper case and more! Accidentally left the caps lock on and typed something, but can’t be bothered to start again and retype it all? Simply follow these following easy steps to convert your text to exactly how you want it. So, let’s try!!

Function:-

function strtosentencecase($s) {
$str = strtolower($s);
$cap = true;
for($x = 0; $x < strlen($str); $x++){
$letter = substr($str, $x, 1);
if($letter == “.” || $letter == “!” || $letter == “?”){
$cap = true;
}elseif(trim($letter) != “” && $cap == true){
$letter = strtoupper($letter);
$cap = false;
}
$ret .= $letter;
}
return $ret;
}

——————————————————————————

Advertisements

WordPress plugin: Tags from comment to your wp post

It’s may be a nice plugin for wordpress developed by me that allows you to post tag to a wordpress post from comment to that post.

Here are three images shows the step how it works.

Step 1: comment submit

Step 2: after submitted comment

Step 3: After approved by admin

May be it helps you to make post better for adding keyword. Enjoy…..

regards,

zakirdaq