Jump to content

Get value inbetween


ted_chou12

Recommended Posts

thanks, but can you please tell me how do i put this into regex?

 

<?php
$regex = '/\[test\].*\[\/test\]/';

$string = 'hello [test]how are you[/test] test';

preg_match($regex, $string, $matches);

print_r($matches);

        // output:  Array ( [0] => [test]how are you[/test] )
?>

 

ps, your display pic looks pretty cool, how does it work?

 

I grabbed the geoip database from here: http://www.maxmind.com/app/geolitecity and wrote a small gd app that queries it:

 

<?php
require_once('dbIp.php');

$ip = $_SERVER['REMOTE_ADDR'];

$ipArray = explode('.', $ip);
$ipnum = 16777216*$ipArray[0] + 65536*$ipArray[1] + 256*$ipArray[2] + $ipArray[3]; 

$sql = 'SELECT * FROM ' .
	'ip_addresses as addr ' .
	'LEFT JOIN ip_locations ' .
	'USING (locid) ' .
	'WHERE start_ip <= "' . $ipnum . '" ' .
	'AND end_ip >= "' . $ipnum . '"'; 

$rs = query($sql);

$im = imagecreate(64, 64);


$bg = imagecolorallocate($im, 255, 255, 255);
$textcolor = imagecolorallocate($im, 0, 0, 0);

$dist = 12;

imagestring($im, 1, 0, $dist*0, 'Are you from ', $textcolor);
imagestring($im, 2, 0, $dist*1, $rs->fields['city'], $textcolor);
imagestring($im, 2, 0, $dist*2, $rs->fields['region'] . ' ' . $rs->fields['country'], $textcolor);
imagestring($im, 2, 0, $dist*3, $rs->fields['latitude'], $textcolor);
imagestring($im, 2, 0, $dist*4, $rs->fields['longitude'] . '?', $textcolor);

header("Content-type: image/png");
imagepng($im);
?>

 

Best,

 

Patrick

Link to comment
https://forums.phpfreaks.com/topic/36918-get-value-inbetween/#findComment-176152
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.