I want PHP to extract the value corresponding to a particular key from the url parameter.

Asked 1 years ago, Updated 1 years ago, 38 views

2 Answers

<?php
// Target URL
$gs_url="https://www.google.co.jp/imgres?imgurl=https://www.irobot-jp.com/roomba/800series/img/lineup_img_03.png&imgrefurl=https://www.irobot-jp.com/roomba/800series/&h=294&w=300&tbnid=hii2NgfRdpdAWM:&docid=6SI3d_RhJqENlM&ei=bRXIVvSuNOasmAXEv6H4BQ&tbm=isch";
// Regular expression patterns:URLs from imgurl to
$pattern='/.*?imgurl=(http.*?.png|http.*?.jpg|http.*?.jpeg|http.*?.gif).*?/';

preg_match($pattern, $gs_url, $matches, PREG_OFSET_CAPTURE);

echo$matches[1][0];
?>


2022-09-30 21:14

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.