Jump to content

IP address last code censored.


ted_chou12

Recommended Posts

<pre>
<?php
// Run 10 tests.
for ($i = 0; $i < 10; $i++) {
	// Generate an IP.
	for ($j = 0; $j < 4; $j++) {
		$ip_pieces[] = rand(1, 255);
	}
	$ip = join($ip_pieces, '.');
	// Run regex.
	printf('%15s => %-15s<br>', $ip, preg_replace('/(\d{1,3}\.\d{1,3}\.\d{1,3}\.)\d+/', '\1xxx', $ip));
	// Reset.
	$ip_pieces = null;
}
?>
</pre>

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.