Answer the question
In order to leave comments, you need to log in
How to break vk url?
I need to know how to break the VK link https://vk.com/wall-1234567_890 into post_id and owner_id variables.
I tried something myself, it doesn’t work, I tried it like parse_url , but even my hosting didn’t understand how this function works, it’s not like you, I don’t even have a brain. In general, I either don’t know how to work with this function, or I don’t know anything at all. Can you help?
Decision:
<?
preg_match('/wall(\d+)_(\d+)/', 'wall-1234567_890', $matches);
list(, $post_id, $owner_id) = $matches;
var_dump($post_id, $owner_id);
?>
Answer the question
In order to leave comments, you need to log in
There are a lot of options. Simplest:
php > preg_match('/wall-(\d+)_(\d+)/', 'https://vk.com/wall-1234567_890', $matches);
php > var_dump($matches);
array(3) {
[0]=>
string(16) "wall-1234567_890"
[1]=>
string(7) "1234567"
[2]=>
string(3) "890"
}
<?php
preg_match('/wall-(\d+)_(\d+)/', 'wall-1234567_890', $matches);
list(, $post_id, $owner_id) = $matches;
var_dump($post_id, $owner_id);
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question