Jump to content

Using php to delete something from a link.


cip6791

Recommended Posts

i would split the original into an array then rebuild it from the parts you want.

<?php
$originalString = "http://www.youtube.com/v/GUHLa1qSy24&rel=0&color1=0x5d1719&color2=0xcd311b&hl=en";

$parts = explode("&",$originalString);

$newString = $parts[0]; // newString = http://www.youtube.com/v/GUHLa1qSy24
$newString.= "&";
$newString.= array_pop($parts); //takes the last value of the array (in this case "hl=en")

echo $newString; // returns: http://www.youtube.com/v/GUHLa1qSy24&hl=en

?>

First explode the color1= part,

it will be split up into 2 parts.

Then split up on the &-mark,

you've got the color tag.

 

I guess this is the easiest way, not the best...

 

 

<?php

$url = 'http://www.youtube.com/v/GUHLa1qSy24&rel=0&color1=0x5d1719&color2=0xcd311b&hl=en';
$color1a = explode("color1=", $url);
$color1b = explode("&", $color1a[1]);
$color1 = $color1b[0];

$color2a = explode("color2=", $url);
$color2b = explode("&", $color2a[1]);
$color2 = $color2b[0];

echo $color1.'<br/>';
echo $color2.'<br/>';

?>

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.