I'm trying to extract the content of the ASIN code in PHP. And I have no idea what I'm doing wrong so that it does not return the string I want to extract.
In this case, I want to extract the content only from the ASIN code ( B01ETRGE7M
) of:
$url = "/Fire-TV-Stick-Basic-Edition/dp/B01ETRGE7M/ref=zg_bs_electronics_1/257-1105669-2334965?_encoding=UTF8&psc=1&refRID=GC2WM7K4BAH0E68ZWRKS";
function asaber($valor){
return preg_match("/^\/[dp]{2}\/\w{10}$/", $valor);
}
echo asaber($url);
The ASIN code:
It is not always the 3rd data in the URL, it can vary from position as it can vary in the letter that starts, since it can also enter numbers.
It will always contain numbers and letters, in uppercase and lowercase.
The URL is from Amazon.