mike16889 Posted July 1, 2008 Share Posted July 1, 2008 im trying to make a script to mass replace the start of some urls. they are to be submitted into a text input box (seporated onto 1 URL per line). but i can't seem to get it to work. i'm sure its simple but hey, i'm a bigginer! <?php $urls = $_POST['urls']; $x = 0; $array = split('\n\r', $urls); $arraysize = count($array); echo $arraysize; while ($x < $arraysize){ echo '<p>'.$array[$x].'</p><p>'.$x.'</p>'; $pos = strrpos ($array[$x], "domain.com"); $urla = str_split($array[$x], $pos); echo '<p>'.$array[$x].'</p>'; $x++; echo '<p><a href="'.$urla[1].'">Link '.$x.'</a></p>'; } ?> well there it is, can't think of anything else i need to tell you exept that its not actualy spliting the stuff up into new lines. Quote Link to comment https://forums.phpfreaks.com/topic/112734-troubles-with-split-function/ Share on other sites More sharing options...
br0ken Posted July 1, 2008 Share Posted July 1, 2008 Are you sure that the delimiter you specified '\r\n' us actually being used? Try changing this to just '\n' or something else and see if the results change. Quote Link to comment https://forums.phpfreaks.com/topic/112734-troubles-with-split-function/#findComment-579006 Share on other sites More sharing options...
mike16889 Posted July 1, 2008 Author Share Posted July 1, 2008 yea i tried that first but decided to chuck the \r in but it didn't work. Quote Link to comment https://forums.phpfreaks.com/topic/112734-troubles-with-split-function/#findComment-579044 Share on other sites More sharing options...
effigy Posted July 1, 2008 Share Posted July 1, 2008 The single quotes treat \n as a literal \n, not a new line. Try "\r\n". Quote Link to comment https://forums.phpfreaks.com/topic/112734-troubles-with-split-function/#findComment-579145 Share on other sites More sharing options...
mike16889 Posted July 2, 2008 Author Share Posted July 2, 2008 cool thanks ill try that whhen i get home Quote Link to comment https://forums.phpfreaks.com/topic/112734-troubles-with-split-function/#findComment-579702 Share on other sites More sharing options...
mike16889 Posted July 2, 2008 Author Share Posted July 2, 2008 Cool that worked but now for some reason its spliting the urls up into chunks of 7 charicters. not rly a problem i just put the following string in echo '<p><a href="http://'.$username.':'.$password.'@'.$urla[1].$urla[2].$urla[3].$urla[4].$urla[5].$urla[6].$urla[7].$urla[8].$urla[9].$urla[10].$urla[11].$urla[12].$urla[13].$urla[14].$urla[15].$urla[16].$urla[17].$urla[18].$urla[19].$urla[20].$urla[21].$urla[22].$urla[23].$urla[24].$urla[25].$urla[26].$urla[27].$urla[28].$urla[29].$urla[30].$urla[31].$urla[32].$urla[33].$urla[34].$urla[35].$urla[36].$urla[37].$urla[38].$urla[39].$urla[40].'">Link '.$x.'</a></p>'; but it someone has a solution id like to here it! THANKS effigy Quote Link to comment https://forums.phpfreaks.com/topic/112734-troubles-with-split-function/#findComment-579732 Share on other sites More sharing options...
Zane Posted July 2, 2008 Share Posted July 2, 2008 do a print_r($_POST) and tell us what you get. or just echo out $urls. We need to see what data you're working with in order to understand you. Quote Link to comment https://forums.phpfreaks.com/topic/112734-troubles-with-split-function/#findComment-579846 Share on other sites More sharing options...
mike16889 Posted July 2, 2008 Author Share Posted July 2, 2008 esentualy just this http://domain.com/stuff/link1.htm http://domain.com/stuff/link2.htm http://domain.com/stuff/link3.htm http://domain.com/stuff/link4.htm http://domain.com/stuff/link5.htm Quote Link to comment https://forums.phpfreaks.com/topic/112734-troubles-with-split-function/#findComment-580026 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.