File tree 1 file changed +17
-0
lines changed
1 file changed +17
-0
lines changed Original file line number Diff line number Diff line change @@ -362,6 +362,23 @@ analysis purposes. Use the ``anonymize()`` method from the
362
362
$anonymousIpv6 = IpUtils::anonymize($ipv6);
363
363
// $anonymousIpv6 = '2a01:198:603:10::'
364
364
365
+ If you need even more anonymization, you can use the second and third parameters
366
+ of the ``anonymize() `` method to specify the number of bytes that should be
367
+ anonymized depending on the IP address format::
368
+
369
+ $ipv4 = '123.234.235.236';
370
+ $anonymousIpv4 = IpUtils::anonymize($ipv4, anonymizedBytesForV4: 3);
371
+ // $anonymousIpv4 = '123.0.0.0'
372
+
373
+ $ipv6 = '2a01:198:603:10:396e:4789:8e99:890f';
374
+ $anonymousIpv6 = IpUtils::anonymize($ipv6, anonymizedBytesForV6: 10);
375
+ // $anonymousIpv6 = '2a01:198:603::'
376
+
377
+ .. versionadded :: 7.2
378
+
379
+ The ``anonymizedBytesForV4 `` and ``anonymizedBytesForV6 `` arguments of
380
+ the ``anonymize() `` method were introduced in Symfony 7.2.
381
+
365
382
Check If an IP Belongs to a CIDR Subnet
366
383
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
367
384
You can’t perform that action at this time.
0 commit comments