richprich
-
Posts
3 -
Joined
-
Last visited
Posts posted by richprich
-
-
Yes, this is the problem of $_SERVER['REMOTE_ADDR'] IP look up. I can't get the domain name if they are using a share IP. Any solution?
-
Hi,
I have an API script provided to people fetching data from my website. Other than stats information, how can I get to know that which websites are connecting my website's API? Any php function that I can include in my API script to get their domain names then insert into my database?
I am php newbie. It would be appreciated if you can post your complete function codes here.
Thanks,
Richard
preg_match_all, then remove duplicate when loop using php
in PHP Coding Help
Posted
Although there are many similar questions and answers here and i've tried my best to make it work but no luck. This is my code:
$content = "Blah...blah...[image=1],
blah...blah...blah...[image=2],
blah...blah...blah...[image=1], no more...";
function get_image($content)
{
$stripper = $content;
preg_match_all("/\[image=(.+?)\]/smi",$stripper, $search);
$total = count($search[0]);
for($i=0; $i < $total; $i++)
{
$image_id = $search[1][$i];
if($image_id > 0)
{
$image = 'This is an image: <img src="images/'.$image_id.'.jpg" />';
}
$stripper = str_replace($search[0][$i], $image, $stripper);
}
return $stripper;
}
I want to remove the duplicate "[image=1]" and return:
Blah...blah...This is an image: <image>,
blah...blah...blah...This is an image: <image>,
blah...blah...blah..., no more...
or
Blah...blah...,
blah...blah...blah...This is an image: <image>,
blah...blah...blah...This is an image: <image>, no more...