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

hi trying to fetch data from t…

hi trying to fetch data from twitter

#mrphpguru My bid won the proj…

#mrphpguru My bid won the project Adding a script to website! http://www.scriptlance.com/projects/1266683884.shtml?ref=mrphpguru

chking aol





chking aol

@mrphpguru #scriptlance My bid…





@mrphpguru #scriptlance My bid won see mrphpguru review http://www.scriptlance.com/projects/1266222488.shtml?ref=mrphpguru

#mrphpguru http://mrphpguru.bl…





#mrphpguru http://mrphpguru.blogspot.com/?spref=tw

mrphpguru#scriptlance My bid w…



mrphpguru#scriptlance My bid won the project Add a script to my website!http://www.scriptlance.com/projects/1266222488.shtml?ref=mrphpguru



how to remove extra space from string using php

how to remove extra space from string using php

Or we can say

Strip extra spaces from the middle of a string

1 way to remove extra space from the middle of the string using php.

<?
$str = “This   is  just          some     text”;

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

echo $str;
?>

2nd way to remove extra space from string is

$str = ”This                                  is  just          some     text”; 

$str=ereg_replace(`  `, ` `, $str);

echo $str; 

Enjoy

mrphpguru

#scriptlance My bid won the pr…





#scriptlance My bid won the project A simple escrow script! http://www.scriptlance.com/projects/1266071234.shtml?ref=mrphpguru

Getting real IP address in PHP

We use $_SERVER['REMOTE_ADDR'] to find out the client’s IP address in PHP.

But some time it dose not returns the true IP address of the client.
Point to noted that if client is connect to the Internet through Proxy Server then $_SERVER['REMOTE_ADDR'] in PHP just returns the IP address of the Proxy Server not of the client’s machine.

So here is a simple function in PHP to find out the real IP address of the client’s machine. There are extra Server variable which might be available to determine the exact IP address of the client’s machine in PHP, they are HTTP_CLIENT_IP and HTTP_X_FORWARDED_FOR.
Simple function to find real IP address in PHP

function get_real_ip_addr()
{
if(!empty($_SERVER['HTTP_CLIENT_IP'])) //check ip from share internet
{
$ip=$_SERVER['HTTP_CLIENT_IP'];
}
else if(!empty($_SERVER['HTTP_X_FORWARDED_FOR'])) //to check ip is pass from proxy
{
$ip=$_SERVER['HTTP_X_FORWARDED_FOR'];
}
else
{
$ip=$_SERVER['REMOTE_ADDR'];
}
return $ip;
}

The above  function return true IP address of  remote machine using PHP.

For this first of all check IP address of the remote machine, if it is false then it will check IP Address is pass from proxy, if yes then it will return otherwise it will return remote computer IP address.

So enjoy

mrphpguru freelancer

founder and CEO

oneanll

how to disable cache form browser using php

How to disable cache form browser using php
Using header function of the php we can disable the browser cache.

Browser cache

header (‘Expires: Mon, 14 Oct 2002 05:00:00 GMT’);

setting the date in past so that browser detect that page has generated in past..


<?
/**
* Disable any caching by the browserfunction disable_browser_cache()
{
@ header ('Expires: Mon, 14 Oct 2002 05:00:00 GMT'); // Date in the past
@ header ('Last-Modified: ' . gmdate ("D, d M Y H:i:s") . ' GMT'); // Always modified
@ header ('Cache-Control: no-store, no-cache, must-revalidate'); // HTTP 1.1
@ header ('Cache-Control: post-check=0, pre-check=0', false);
@ header ('Pragma: no-cache'); // HTTP 1.0
}

//how to call this function

// Disable any caching by the browser
disable_browser_cache();
?>

so u are seing the above function to disable the cache from the browser using php.

so u can see using header function of php we can disable browser cache…

mrphpguru