Search the Community
Showing results for tags 'strings'.
-
Hi all, I am using foreach statement to gather records and program levenshtein to detect any misspellings and suggesting the correct words. The thing is i am unable to convert all those strings into a single array. After trying to correct this issue so many times, i wonder if it is really possible to convert strings into a single array? Any input is welcome
-
Hi this is my first post after registering here. Please help me. I have a string of user data comma separated as below and pipe separated.I have been trying to remove duplicates by converting it to array. And even with php But it all does not works. My data looks like below: Marja_Roxburgh|abc@abc.com|123-456-7890|N/A|2011-11-17|N/A|N/A|N/A|N/A|N/A|120, Santa_Roxburgh|bmw@abc.com|123-456-7890|N/A|2013-11-17|N/A|N/A|N/A|N/A|N/A|10, Marja_Roxburgh|abc@abc.com|123-456-7890|N/A|201-11-17|N/A|N/A|N/A|N/A|N/A|300, Saga_Shera|xyz@abc.com|123-456-7890|N/A|2013-11-17|N/A|N/A|N/A|N/A|N/A|0, Marja_Roxburgh|abc@abc.com|123-456-7890|N/A|2013-11-17|N/A|N/A|N/A|N/A|N/A|120 I have tried What's the best way to remove duplicates from a string in PHP (or any language)?, detecting duplicate string in a explode function php and like this How to detect duplicate values in PHP array? one too. But none of these works in my case. Coz my data is not unique for same User say Marja_Roxburgh. I wants to remove all entries of Marja_Roxburgh based on its email but also wants to keep the first one only and sum all amounts from its transactions. I've been googling for any logic Im not able to understand what to do this it. How Do I keep only first Record of Marja_Roxburgh and remove all other of her. And also sum all her Amounts before removing her data? I'm missing the logic to understand and solve this problem. Can somebody help me understand this logic? any Ideas? Thanks
-
I have these files in a directory and can easily list to a webpage Daily_CD_20130902.xml Daily_CD_20130903.xml Daily_CO_20130902.xml Daily_CO_20130903.xml Daily_CU_20130902.xml Daily_CU_20130903.xml Daily_EQ_20130902.xml Daily_EQ_20130903.xml Daily_IR_20130902.xml Daily_IR_20130903.xml However, i want to be selective and just select the most recent of each type, so instead of the whole list i want to display Daily_CD_20130903.xml Daily_CO_20130903.xml Daily_CU_20130903.xml Daily_EQ_20130903.xml Daily_IR_20130903.xml Is there an easy way to do this or do i need to take apart the filename, put the date in a date object and then use it to sort. my current code is: public function getFiles() { //return String, form as HTML later $return = ""; // create a resrouce pointing to the directory with the files in it on disk $dir = opendir('DIRECTORY'); //path to that directory that is appended to the URL $actualdir = 'PATH FROM WEBSERVER ROOT'; // read the directory looping over the files and populate to an array while ($entryName = readdir($dir)){ $dirArray[] = $entryName; } //close the directory as we don't need it anymore closedir($dir); //make a note of how many items are in the directory $indexCount = count($dirArray); //loop through the files building up a list of links for($index=0; $index < $indexCount; $index++) { if($dirArray[$index] !="." && $dirArray[$index] !=".."){ $return .= "<a href='"."$actualdir".$dirArray[$index]."'>".$dirArray[$index]."</a><br/>"; } } return $return; } any help is appreciated as this is my first day of PHP