riceje7 Posted November 23, 2009 Share Posted November 23, 2009 so i have this project due tomorrow and i can't seem to get my code to work, i'm trying to check the values of user input to a list of stop words for a tag cloud, however it doesn't seem to work at all. i've trie unset(), array_splice(), and tried just creating a new array. any help at all would be incredible. attached is my code, the code that is supposed to remove the stop words from the array is called removeswords.php. thanks a bunch [attachment deleted by admin] Link to comment https://forums.phpfreaks.com/topic/182670-need-help-asapproject-due-tomorrow/ Share on other sites More sharing options...
abazoskib Posted November 23, 2009 Share Posted November 23, 2009 you'll get more help if you only post the parts of the code that arent working. Link to comment https://forums.phpfreaks.com/topic/182670-need-help-asapproject-due-tomorrow/#findComment-964108 Share on other sites More sharing options...
riceje7 Posted November 23, 2009 Author Share Posted November 23, 2009 <?php function removeswords(&$arraytotrunc){ $tempfilename = "stopwords.txt"; $fp = fopen($tempfilename, "r"); $tempdata = fread($fp, filesize($tempfilename)); fclose($fp); $swords = array(); $swords = parsetext($tempdata); foreach($swords as $key => $value){ //echo($key."=>".$value."<br/>"); } $newarray = array(); foreach($arraytotrunc as $key => $value){ //echo($key."<br/>"); for($i = 0; $i < sizeof($arraytotrunc); $i++){ for($x=0;$x < sizeof($swords); $x++){ if($key != $swords[$x]){ $newarray[$i] = $key; //removeswords($arraytotrunc); } } } } //$truncarray = array_values($arraytotrunc); $temparray = array_values($newarray); //var_dump($temparray); return $newarray; } ?> Link to comment https://forums.phpfreaks.com/topic/182670-need-help-asapproject-due-tomorrow/#findComment-964126 Share on other sites More sharing options...
abazoskib Posted November 23, 2009 Share Posted November 23, 2009 riceje7, can you explain your problem with an example? maybe post an example function call, and the output you are expecting? i am having trouble understanding your problem. Link to comment https://forums.phpfreaks.com/topic/182670-need-help-asapproject-due-tomorrow/#findComment-964161 Share on other sites More sharing options...
sasa Posted November 23, 2009 Share Posted November 23, 2009 look array_diff() function Link to comment https://forums.phpfreaks.com/topic/182670-need-help-asapproject-due-tomorrow/#findComment-964188 Share on other sites More sharing options...
riceje7 Posted November 23, 2009 Author Share Posted November 23, 2009 array_diff() worked, thanks sasa! Link to comment https://forums.phpfreaks.com/topic/182670-need-help-asapproject-due-tomorrow/#findComment-964267 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.