0

Hello ,

I have this error Deprecated: Function split() is deprecated.
How can i resolve this problem.
I use explode and preg_split but the problem persist

                    $add=long2ip($result["ip_src"]);
                    $mask="24";
                    $ipNetmask = $add."/".$mask;
                    list($ip, $netmask) = split("/", $ipNetmask );
                    $ip_elements_decimal = split("[.]", $ip );
                    $netmask_result="";
                    for($i=1; $i <= $netmask; $i++) {
                      $netmask_result .= "1";
                    }
                    for($i=$netmask+1; $i <= 32; $i++) {
                        $netmask_result .= "0";

                    }
                    $netmask_ip_binary_array = str_split( $netmask_result, 8 );
                    $netmask_ip_decimal_array = array();
                    foreach( $netmask_ip_binary_array as $k => $v ){
                        $netmask_ip_decimal_array[$k] = bindec( $v ); // "100" => 4
                        $network_address_array[$k] = ( $netmask_ip_decimal_array[$k] & $ip_elements_decimal[$k] );
                    }
                    $network_address = join( ".", $network_address_array );
2
Contributors
2
Replies
12
Views
3 Years
Discussion Span
Last Post by jarmouz
1

If you replace the following code:

list($ip, $netmask) = split("/", $ipNetmask );
$ip_elements_decimal = split("[.]", $ip );

with this one (for IPv4 addresses):

list($ip, $netmask) = explode("/", $ipNetmask );
$ip_elements_decimal = explode(".", $ip );

you should not get the depreciated notice. In fact I think you do not need regular expressions (with their overhead) for this.

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.