Send array in Ajax with PHP

On js page
dataString =  // your array
var jsonString = JSON.stringify(dataString);
   $.ajax({
        type: "POST",
        url: "script.php",
        data: {data : jsonString}, 
        cache: false,

        success: function(){
            alert("OK");
        }
    });

On php  page 
$data = json_decode(stripslashes($_POST['data']));

// it will return array 
 

How to check URL is valid or not in PHP?

<?php
$weburl = "http://www.mywebsite.com";

// Remove invalid characters from URL
$weburl = filter_var($weburl, FILTER_SANITIZE_URL);

// Validate web url
if (!filter_var($weburl, FILTER_VALIDATE_URL) === false) {
echo("$weburl is a valid.");
} else {
echo("$weburl is not a valid.");
}
?>