mysterbx Posted January 26, 2008 Share Posted January 26, 2008 How can I make this line work? preg_match_all("#(^|[\n ])([\w]+?://[^ \"\n\r\t<]*)#ise", $htmlbody, $links); when i use print_r($links); it return results: Array ( [0] => Array ( [0] => http://txt.com/files/8452782/txt_1_1.wmv [1] => http://txt.com/files/8452702/txt_1_2.wmv [2] => http://txt.com/files/8452734/txt_2_1.wmv [3] => http://txt.com/files/8452328/txt_2_2.wmv [4] => http://txt.com/files/8452922/txt_3_1.wmv [5] => http://txt.com/files/8452796/txt_3_2.wmv [6] => http://txt.com/files/8452355/txt_4_1.wmv [7] => http://txt.com/files/8452770/txt_4_2.wmv [8] => http://txt.com/files/8452753/txt_5_1.wmv [9] => http://txt.com/files/8452802/txt_5_2.wmv [10] => http://txt.com/files/8452774/txt_6_1.wmv [11] => http://txt.com/files/8452694/txt_6_2.wmv [12] => http://txt.com/files/8452458/txt_7_1.wmv [13] => http://txt.com/files/8452795/txt_7_2.wmv [14] => http://txt.com/files/8452690/txt_8_1.wmv [15] => http://txt.com/files/8452762/txt_8_2.wmv [16] => http://txt.com/files/8452754/txt_9_1.wmv [17] => http://txt.com/files/8452751/txt_9_2.wmv [18] => http://txt.com/files/8452769/txt_10_1.wmv [19] => http://txt.com/files/8452720/txt_10_2.wmv ) [1] => Array ( [0] => [1] => [2] => [3] => [4] => [5] => [6] => [7] => [8] => [9] => [10] => [11] => [12] => [13] => [14] => [15] => [16] => [17] => [18] => [19] => ) [2] => Array ( [0] => http://txt.com/files/8452782/txt_1_1.wmv [1] => http://txt.com/files/8452702/txt_1_2.wmv [2] => http://txt.com/files/8452734/txt_2_1.wmv [3] => http://txt.com/files/8452328/txt_2_2.wmv [4] => http://txt.com/files/8452922/txt_3_1.wmv [5] => http://txt.com/files/8452796/txt_3_2.wmv [6] => http://txt.com/files/8452355/txt_4_1.wmv [7] => http://txt.com/files/8452770/txt_4_2.wmv [8] => http://txt.com/files/8452753/txt_5_1.wmv [9] => http://txt.com/files/8452802/txt_5_2.wmv [10] => http://txt.com/files/8452774/txt_6_1.wmv [11] => http://txt.com/files/8452694/txt_6_2.wmv [12] => http://txt.com/files/8452458/txt_7_1.wmv [13] => http://txt.com/files/8452795/txt_7_2.wmv [14] => http://txt.com/files/8452690/txt_8_1.wmv [15] => http://txt.com/files/8452762/txt_8_2.wmv [16] => http://txt.com/files/8452754/txt_9_1.wmv [17] => http://txt.com/files/8452751/txt_9_2.wmv [18] => http://txt.com/files/8452769/txt_10_1.wmv [19] => http://txt.com/files/8452720/txt_10_2.wmv ) ) but when i enter return $links[2]; or any other number i get nothing... i just see "ArrayArrayArrray" can you help me fix this preg_match_all into working line? maybe it need to be preg_match or preg replace... i dont know... i just need to list all the links like this: http://link1 http://link1 http://link1 http://link1 ... Quote Link to comment Share on other sites More sharing options...
laffin Posted January 26, 2008 Share Posted January 26, 2008 U dun undertsand how preg_match_all works, it's doing exactly as u told it.... preg_match_all is returning an array, with arrays of the groups captures. since u only have 2 groups, u will have an array of an array with 3 arrays 1st array the match string itself 2nd array the first capture group 3rd array the 2nd capture group from the looks of things you want to process the 3rd array, your 2nd capture group. return $links[2] wud return an array of each (an array) but to display an item from those links $links[2][0] wud be the first item caught or use a foreach($links[2] as $link) echo "$link<br>"; Quote Link to comment Share on other sites More sharing options...
mysterbx Posted January 26, 2008 Author Share Posted January 26, 2008 works fine thanks a lot! what about this, $text = "Password: somethin P/W somethin2 pass sth"; preg_match_all should find all passwords until \n or \t or \r and list them in one line im working on this script for a few days, I cant make it work, if i do, it works for one text, but not for other, and oppositivly this is almost the last piece to my script Quote Link to comment Share on other sites More sharing options...
laffin Posted January 26, 2008 Share Posted January 26, 2008 preg_match_all('@(.*)[\t\r\n]@',$sub,$matches); $matches[1] will contain the list of passwords Quote Link to comment Share on other sites More sharing options...
mysterbx Posted January 26, 2008 Author Share Posted January 26, 2008 how it'll know whenever its a password or a link if the text is: $text = "Title:Nokia Games Pack Info: more than 1k games! link to download http://somelink.com Password to open: mypass or try this pass: mypass2 P/W mypass3 or password: mypass5"; ofcourse there wount by so many password, but you'll never know Quote Link to comment Share on other sites More sharing options...
mysterbx Posted January 26, 2008 Author Share Posted January 26, 2008 is there a way to do that? Quote Link to comment Share on other sites More sharing options...
mysterbx Posted January 26, 2008 Author Share Posted January 26, 2008 almost got it... preg_match_all("#([\n\s])((Password(\:|)|pw\:|Pass(\:|))[\s\n\r\t\S<][^\n\t\r]*)#ise", $fix, $pass); it find's the passwords, but shows it like this: Password somekindaword pass: somekindaword2 but it should look like this: somekindaword, somekindaword2 please help me, its the last component... Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.