PHP - Extract Information From Youtube Into A String
Hello,
Anyone know a way I could extract information from YouTube. If I have the URL for the video, how could I get the title, runtime, tags and so on into different strings? url = "http://www.youtube.com/watch?v=kMAI26FPeyM"; Thanks Similar Tutorialshello, I want to extract a youtube video variable from users comments, i make a simple function but it works just for one url, if they posted more urls in the same comment, it will return just the first video. this is what i've done before now: Code: [Select] function get_youtube ($youtube){ $findme = 'youtube.com/watch?v='; $pos = strpos($youtube, $findme); if ($pos !== false) { parse_str( parse_url( $youtube, PHP_URL_QUERY )); echo $v; } } How can I make to extract all the $v from a comment with more url? thanks Hello I post this message because I am trying to extract information from a site that has the same system of visacentral, I cannot give access to this system because is in a Intranet, but the system is more or less the same that this site: visacentral.co.uk/ajax/ajax.visaPopup.php?passport_from=BOL&traveling_to[0]=BHS&traveling_for%5B0%5D=T&traveling_to%5B1%5D=&traveling_for%5B1%5D=&traveling_to%5B2%5D=&traveling_for%5B2%5D=&traveling_to%5B3%5D=&traveling_for%5B3%5D=&account_number=BRITTRAV&account_exists=N The problem that I have either I use CURL or file_get_contents then they have a redirection and I cannot get the final content from http://visacentral.co.uk/requirements.php Someone has any idea how this can be done? Thank you very much!! I've been trying to get this to work for a few days now and can't seem to get anywhere with it! Any help is very much appreciated. I am creating a number generator where the user is required to insert the maximum number and generate rate. Maximum number is the highest number that the script will go to, and generate rate is how many numbers should be created. When the script runs, the numbers are stored into a MySQL database. The MySQL database creates a unique ID number so it can be recalled at a later date. The user then needs to go to Sorting.php and selects the record they wish to use. The numbers from this record are then counted and then stored into an array. If the numbers 2,5,5,0,2,2,1,3,5,1 where generated, the output of this new array will be: [5] => 3 [3] => 1 [2] => 3 [1] => 2 => 1 (These arrays can be of any length) I now need to extract this data and show it on screen. I don't know how to approach it. Format example: Number 5 appears 3 times Number 3 appears 1 times Number 2 appears 3 times Number 0 appears 1 times Sorting.php <?php $db1 = new Number_Information(); $db1->openDB(); $sql = "select * from GeneratedNumber"; $result = $db1->getResult($sql); if (!$_POST) { //page loads for the first time ?> <form action="<?php echo $_SERVER['PHP_SELF'] ?>" method="post"> Select the ID (If you have just generated a number, it will be the last one): <!--This is the drop down menu--> <select name="ID"> <?php while ($row = mysql_fetch_assoc($result)) { echo "<option value='{$row['ID']}'> {$row['ID']} </option>"; } ?> </select> <br /> <input type="submit" value="Continue" /> </form> <?php } else { $ID = $_POST['ID']; //This will contain the value that was selected in the drop down menu above. $result = mysql_query("SELECT NUMBERS2 FROM GeneratedNumber WHERE ID='{$ID}'"); //This tells the script to select NUMBERS2 contents which is assosiated with the ID. while ($row = mysql_fetch_array($result)) $NUMBERS2 = $row['NUMBERS2']; echo "$NUMBERS2"; //Testing reasons - remove it later. echo "<br />"; //same as above echo "$ID"; // as above. echo "<br />"; //as above //Convert NUMBERS2 back into an array when inserted into table from Generator.php $NUMBERS = explode(",", $NUMBERS2); // Counts how many times a number appears //******************************************************************************************************************* //IF ALL ELSE FAILS, REVERT BACK TO THIS. //print_r(array_count_values($NUMBERS)); //It will only print the statement, but gives you a good building block when things WILL go wrong. //******************************************************************************************************************* rsort($NUMBERS); print_r(array_count_values($NUMBERS)); (The questions when editing posts are hard. I've needed to Google both of them:() Problem: "Warning: extract() expects parameter 1 to be array, null given in C:\x\xampp\htdocs\pages\user_personal.php on line 32" - error also found on lines 33 and 38. and none of the information is displayed. Goal: I'm trying to retrieve profile information and multiple user inserted pictures and display the pictures through a while loop from one query. <?php $query = 'SELECT u.name_id, i.bio, i.exhib, p.product_code FROM user u LEFT JOIN profile i ON u.name_id = i.name_id LEFT JOIN ecomm_products p ON u.name_id = p.product_code WHERE u.name = "' . mysql_real_escape_string($_SESSION['name'], $db) . '" and p.name = "' . mysql_real_escape_string($_SESSION['name'], $db) . '"'; $result = mysql_query($query, $db) or die(mysql_error()); extract($bio); //line 32 extract($exhib); //line 33 $odd = true; while ($row = mysql_fetch_array($result)) { echo ($odd == true) ? '<tr class="odd_row">' : '<tr class="even_row">'; $odd = !$odd; extract($rows); line 38 echo '<td><a href="' . $dir . '/' . $row['product_code'] . '.jpg">'; echo '<img src="' . $thumbdir . '/' . $row['product_code'] . '.jpg">'; echo '</a></td>'; echo '</tr>'; } echo "</table>"; echo "<p>"; ?> <ul> <li>Biography: <?php echo $bio; ?></li> <li>Exhibitions: <?php echo $exhib; ?></li> </ul> http://www.abc.com/sports/more/others/Younger-people/show/7321382.xml http://www.abc.com/news/head/Elder-people/show/7321302.xml In the above string,please tell me how to extract the portion, and store "sports/more/others" and "news/head" in another string. Folks, Quote http://natty.com/p/bh-fitness-class-indoor-magnetic-exercise-bike-2-years-parts-/detail/b004r2wuak/fitness-spinning.html From this url String, i want to extract the last part of string which is, "fitness spinning". This URL is dynamic an can have any value in that last bit, so how to extract anything btween Two Forward slashes just before .html? Note: It can not be extracted with GET as its not how its designed. Thanks Natasha I need to extract "C:\Documents and Settings" from the last line of this data every time it appears. It is always between DirectoryName REG_SZ and HKEY. DirectoryName REG_SZ C:\Documents and Settings HKEY How can I extract "C:\Documents and Settings" or whatever the value is multiple times using PHP? Hi i have a string which contains some text and 2 links for example. How could i extract all the string minus one of the links eg $textstring = "some text before <a href="testpage.php"> <img src="image1.jpg" /></a> <a href="testpage2.php"> <img src="image2.jpg" /></a> some text after " i would like to make a create a new string which contains all this text minus the first link $newstring = "some text before <a href="testpage2.php"> <img src="image2.jpg" /></a> some text after " any ideas? I just managed to login to a forum using curl, but then I found out I had to extract the session id before I could start posting. The session id is in a string like this: sesc=b97b74351fde8dfbac7391af1f054de9 How do I extract the value b97b74351fde8dfbac7391af1f054de9 if I know that it comes righ behind "sesc=". I think I am supposed to use strpos, but I don't know. I have string like this (without the spaces) [ QUOTE="Adrock"]This is a test message[/QUOTE ] How do i get just what is between the double quotes taking into account in the message there could be double quotes? I've tried this but it doesn't echo anything unless i put the square brackets in but i want the username $origauth = html_entity_decode($message); $b = substr($origauth, strpos($origauth, '&#034') + 1); $c = substr($b, 0, strpos($b, '&#034')); echo $c; Hi i need help with some string manipulation and extraction.. http://www.test.com/forums/attachment/f39/745d1267084199-official-ar-m16-m4-picture-thread-dsc00005.jpg I need to extract an id from the above path dynamically. I need to extract the digits before the alphabet d after the second last path f39/ In the above case the number extracted would be 745. Can someone please help me out with it? I'm not sure if this is possible
Previously I had a problem of outputting rows of a specific query
This was the solution that was given to me
$txt .= $date . " " . $stratoparse . "\n\n";Where a while loop's results were concatenated to a single string What I would like to do is output the results in individual containers with controls such as dragging for repositioning / an x for deletion That's not what I'm here for in this post I want to embed youtube videos, so they are not just stored as links, rather a clickable video so if you have something like string.string2.string3.string4.string5.<iframe src="youtube"...>.string7.string8 how would that video be isolated and parsed / understood as a front end youtube video ? To provide a brief background in case you are wondering why in my right mind, I would want to do this... First it is the primary solution that comes to mind going off what already works Secondly, the purpose or point of the concatenated string comes from the "application" design which is a store and recall interface. Vague, I know. The website has multiple users and they all have access to a single database. They save random strings, whether they are paragraphs or links, possibly videos that are uploaded, etc... these are saved by a keyphrase, later recalled by searching that keyphrase. Currently the output is nothing more than a concatenated string, that was fine initially but some of my friends have been testing the website and they made suggestions which are good such as repositioning and deleting entries. Now I want to automatically parse youtube links into embedded videos... I'll probably use that explode "function" to disect the link and place the url within the src=" " Anyway, I have to look into this but if anyone has any thoughts I'd appreciate it. Edited by moose-en-a-gant, 11 January 2015 - 02:05 AM. Can anyone help me output "Zinfandel|Sauvignon Blanc" from "This very nice wine is produced in California and is made from Zinfandel and Sauvignon Blanc grapes."?
Please also notice the case insensitivity. I prefer the output with capitals on first words.
I created the following code :
<?php $ds = "Riesling|Sauvignon Blanc|Zinfandel|Muscat/i"; $string = "This very nice wine is produced in California and is made from zinfandel and Sauvignon Blanc grapes."; echo "This is the string to extract the grapes from : "; echo $string; echo "<br>"; echo "These are the grapes that need to be matched in a regular expression : "; echo $ds; echo "<br>"; $matches = array(); $search = preg_match_all($ds, $string, $matches); foreach ($matches[1] as $match) { echo $match; // I want this to output "Zinfandel|Sauvignon Blanc" with a pipeline between the matches } ?>Any help pretty much appreaciated! Hi, I am very new to PHP and apologies if this question has already been answered in another thread.
I am trying to extract the information from one array into another when some search criteria is matched.
Here is an example array ($original):
Array ( [ 1234567 ] => Array ( [name] => john ) [ 3456 ] => Array ( [name] => johnny ) [ 45673 ] => Array ( [name] => james ) [ 987 ] => Array ( [name] => jamie ) [ 5628721 ] => Array ( [name] => Simon ))
So if I searched for the string john, jo, joh then the new array ($filtered) should be as follows:
Array ( [ 1234567 ] => Array ( [name] => john ) [ 3456 ] => Array ( [name] => johnny ))
I was trying to do this using array_search & preg_match but have been struggling.
Any help would be much appreciated!
Hi, I am trying to find a way that will allow me to convert information passed via POST into array so I can run foreach on the array. For example if information in $_POST[ids] is 1000, 1001, 1002, 1003 I would like to get it into an array $array = array("1000", "1001", "1002", "1003") Thanks This topic has been moved to Third Party PHP Scripts. http://www.phpfreaks.com/forums/index.php?topic=321546.0 So I have been working on my website for a while which all is php&mysql based, now working on the social networking part building in similar functions like Facebook has. I encountered a difficulty with getting information back from a link. I've checked several sources how it is possible, with title 'Facebook Like URL data Extract Using jQuery PHP and Ajax' was the most popular answer, I get the scripts but all of these scripts work with html links only. My site all with php extensions and copy&paste my site links into these demos do not return anything . I checked the code and all of them using file_get_contents(), parsing through the html file so if i pass 'filename.php' it returns nothing supposing that php has not processed yet and the function gets the content of the php script with no data of course. So my question is that how it is possible to extract data from a link with php extension (on Facebook it works) or how to get php file executed for file_get_contents() to get back the html?
here is the link with code&demo iamusing: http://www.sanwebe.c...-php-and-jquery
thanks in advance.
How could I from the varying URLs parse only the YouTube video ID? http://www.youtube.com/watch?v=SwrawcORlp0&feature=player_embedded http://www.youtube.com/watch?v=SwrawcORlp0&feature=popular How can I from the URLs above only extract the id into a variable $url SwrawcORlp0 Thanks, df hello, I am trying to figure out how I can take only the v= in the youtube urls http://www.youtube.com/watch?v=nGawAhRjtoA&feature=topvideos i just want php to take v=nGawAhRjtoA and ignore everything else any ideas guys/gals? thanks |