Jump to content

Recommended Posts

if wee have

$description =[/color][font=monospace][size=1]<strong>[/size][/font][color=#000000][font=monospace][size=1]Svetaca [/size][/font][/color][font=monospace][size=1]</strong>[/size][/font][color=#000000][font=monospace][size=1]na „Mestalji“ u prvom meču osmine finala Lige šampiona, pristalice pariskog kluba su istakle transparent [/size][/font][/color][font=monospace][size=1]<strong>[/size][/font][color=#000000][font=monospace][size=1]„Kosovo je Srbija“[/size][/font][/color][font=monospace][size=1]</strong>[/size][/font][color=#000000][font=monospace][size=1] na engleskom jeziku, uz srpsku trobojku.[/size][/font][/color][font=monospace][size=1]</p>[/size][/font][font=monospace][size=1]<p>[/size][/font][font=monospace][size=1]<object classid=\"clsid:d27cdb6e-ae6d-11cf-96b8-444553540000\" width=\"425\" height=\"350\" codebase=\"http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,40,0\">[/size][/font][font=monospace][size=1]<param name=\"src\" value=\"http://www.youtube.com/v/ri2RXhr4FS8\" />[/size][/font][font=monospace][size=1]<embed type=\"application/x-shockwave-flash\" width=\"425\" height=\"350\" src=[url="http://sportskevesti.co/%22http://www.youtube.com/v/ri2RXhr4FS8/%22"]\"http://www.youtube.com/v/ri2RXhr4FS8\"[/url]>[/size][/font][font=monospace][size=1]</embed>[/size][/font][font=monospace][size=1]</object>[/size][/font][font=monospace][size=1]</p>[/size][/font][font=monospace][size=1]<p>[/size][/font][color=#000000][font=monospace][size=1]U pitanju je navijačka grupa [/size][/font][/color][font=monospace][size=1]<strong>[/size][/font][color=#000000][font=monospace][size=1]Karsud[/size][/font][/color][font=monospace][size=1]</strong>[/size][/font][color=#000000][font=monospace][size=1], koja sebe smatra ultrasima i nije na dobrom glasu u Francuskoj zbog huliganizma.[/size][/font][/color][font=monospace][size=1]</p>[/size][/font][font=monospace][size=1]<p>[/size][/font][color=#000000][font=monospace][size=1]Isti transparent navijači [/size][/font][/color][font=monospace][size=1]<strong>[/size][/font][color=#000000][font=monospace][size=1]

 

How wee can extract only youtube link?

Edited by ebchost
Link to comment
https://forums.phpfreaks.com/topic/274445-get-youtube-from-string/
Share on other sites

if wee have

$description =[/color]<strong>Svetaca </strong>na „Mestalji“ u prvom meču osmine finala Lige šampiona, pristalice pariskog kluba su istakle transparent <strong>„Kosovo je Srbija“</strong> na engleskom jeziku, uz srpsku trobojku.</p><p><object classid=\"clsid:d27cdb6e-ae6d-11cf-96b8-444553540000\" width=\"425\" height=\"350\" codebase=\"http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,40,0\"><param name=\"src\" value=\"http://www.youtube.com/watch?v=ri2RXhr4FS8\" /><embed type=\"application/x-shockwave-flash\" width=\"425\" height=\"350\" src=\"http://www.youtube.com/watch?v=ri2RXhr4FS8\"></embed></object></p><p>U pitanju je navijačka grupa <strong>Karsud</strong>, koja sebe smatra ultrasima i nije na dobrom glasu u Francuskoj zbog huliganizma.</p><p>Isti transparent navijači <strong>

 

How wee can extract only youtube link?

I understand now what is the problem...

 

There's nothing wrong with the display, because contains a lot of tags :) (copy paste from 'View Page source')

 

$string = "tags, text, <embed  youtube link >, ....";

 

Q: How to get youtube link from $string get youtube link?

Edited by ebchost

You need to paste the code as plain text, as it's copying the colors over too. Which is messing things up.

 

As mentioned, you would use a DOM parser or a regular expression. DOM parser would probably be easiest.

 

http://www.php.net/manual/en/function.preg-grep.php

http://php.net/manual/en/book.dom.php - Note that there are 3rd party libs which may be even easier to use

you could go kinda ghetto, and do something like

 

<?php
$data='stufwlkef weljflwkejflwfjwf src=\'http://www.youtube.com/v/rifw235SG\"><etc etc tec...';

$start_pos=strpos($data, 'http://www.youtube.com');
$end_pos=strpos($data, '\">', $start_pos);

$link=substr($data, $start_pos, ($end_pos - $start_pos));

echo $link;
?>

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.