Monday, 9 May 2011

Find any part of string in another string & manipulate accordingly

<?php
$string = 'www.google.com';//string
$ss = strpos($string,'http://');//cheking whether the part of string exist in full string or not
if($ss!==false)//if exists
{
  $string = $string;
}
else
{
  $string = 'http://'.$string;
}
echo $string;//final string.
?>

No comments:

Post a Comment