game.onenall.com,play free game online game.onenall.com,play free game online game.onenall.com,play free game online game.onenall.com,play free game online game.onenall.com,play free game online game.onenall.com,play free game online game.onenall.com,play free game online game.onenall.com,play free game online

how to break a sentance after some words using php

wordrap php

Today we will see how to break a sentance after some characters using php.

Sometime we need to break a long line into small peaces of sentence to meet the designing   requirement. PHP has very good function wordwrap() to meet the req.

Basic sentance of the wordwrap() php function

string wordwrap ( string $str [, int $width = 75 [, string $break = "\n" [, bool $cut = false ]]] )

So u can see by default, wordwrap() uses a column width of 75 characters. This means that no line will be more than 75 characters long.

Wrapping very long words

For example suppose we have a sentance:

$sentance = ‘JohnCleese: Have you signed up to my monthly email yet? Youre missing outif you havent http://aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa.co.uk/‘;

echo "<pre>" . wordwrap( $sentance, 10 ) . "</pre>";

output will be: 
JohnCleese:
Have you
signed up
to my
monthly
email yet?
Youre
missing
outif you
havent!

http://aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa.co.uk/

So you can see the problem at last sentence.

To make this work perfectly use the sentence like this

<?
$sentance = 'JohnCleese: Have you signed up to my monthly email yet? Youre missing outif you havent! http://aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa.co.uk/';
echo "<pre>" . wordwrap( $sentance, 10, "\n", true ) . "</pre>";
?>

Output will be like:

JohnCleese
: Have you
signed up
to my
monthly
email yet?
Youre
missing
outif you
havent!

http://aaa

aaaaaaaaaa
aaaaaaaaaa
aaaaaaaa.c
o.uk/

So clear now.
Thanks
mrphpguru
http://www.mrphpguru.com


strpos function to check character in string using php

strpos function to check character in string using php

suppose i would like to find : in string so chk this out

$username = ’mrphpguru:aphp coder’;
$pos = strpos($username, ”!”);
if ($pos == -1)
{
print Please ‘don’t put : in your usernames’;
}
else
{
print ’No special character in the string.Thanks’;
}

So using strpos function we can find a character in a string using php function strpos.

thanks

mrphpguru

How to remove extra spaces from the middle of a string





Strip extra spaces from the middle of a string

Hi php code here is a simple code or function to remove all extra space from the string using php

<?
$str = ”Hi   I am    mrphpguru a php         programmer to             develop any webiste           please          contact me         using mrphpguru@gmail.com”;

// use two spaces for the seperator
while (sizeof ($array=explode (“  “,$str)) != 1)
{
// use one space for the glue
$str = implode (” “,$array);
}

echo $str;
?>

Result: Hi   I am mrphpguru a php  programmer to  develop any webiste please contact me using mrphpguru@gmail.com

Thanks

mrphpguru