简体   繁体   中英

How to get ID from Instagram URL using preg_match

i need to know how to preg_match ID from instagram URL

https://www.instagram.com/p/BrODgnXHlE6/?utm_source=ig_share_sheet&igshid=znsinsart176

i tried

preg_match('/https://www.instagram.com/p/(. )/(. )/U', $video_url, $matches);

$video_id = $matches[1];

But it is not working Thank you

<?php
$url = "https://www.instagram.com/p/BrODgnXHlE6/?utm_source=ig_share_sheet&igshid=znsinsart176";
preg_match('/https:\/\/www.instagram.com\/p\/(.+)\/(.+)/U', $url, $matches);
$id = $matches[1];

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM