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 );

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.

Thank you very much. its works

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.