简体   繁体   English

如何使用preg_match从Instagram URL获取ID

[英]How to get ID from Instagram URL using preg_match

i need to know how to preg_match ID from instagram URL 我需要知道如何从instagram URL进行preg_match ID

https://www.instagram.com/p/BrODgnXHlE6/?utm_source=ig_share_sheet&igshid=znsinsart176 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); 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];

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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