nephesh
-
Posts
22 -
Joined
-
Last visited
Posts posted by nephesh
-
-
One question though, why would I need to return "false" if nothing is found? It will always find something. And when I've tried adding it as below it doesn't return the correct results. (Also, to make this clear the file paths in the array don't contain the extension.)
function array_search_partial($arr, $keyword) { foreach ($arr as $index => $string) { $userBase = basename($string); $test = substr_count($userBase, '-'); if($test === 2) { if(preg_split("/[-]+/", $userBase)[2] == $keyword) { return $index; } else { return false; } } }
-
Thanks for everyone's help with this! I've got it working perfectly!
-
I believe I've got it! Does this seem correct to you?
function array_search_partial($arr, $keyword) { foreach ($arr as $index => $string) { $userBase = basename($string); $test = substr_count($userBase, '-'); if($test === 2) { if(preg_split("/[-]+/", $userBase)[2] == $keyword) { return $index; } } } }
-
That might have worked if I needed the whole filename. I need from the end to the first "-" (hyphen) to compare to the $keyword. (eg. lastname-firstname-username) Need to isolate username.
-
I have a array of file path strings and trying to search the array for a string that would be the end of the path sting and return the index of the file path that contains the string. I've tried using something like this, but it finds the keyword in anyplace in the file path. I've also tried strripos() as well with the same results. Any suggestions?
function array_search_partial($arr, $keyword) { foreach ($arr as $index => $string) { if(strpos($string, $keyword) !== FALSE) { return $index; } } }
-
Ok, then how do I get the mysqld process started?
-
I am trying to manually install MySQL 5.5 on windows 7 64bit. I've extracted the zip to the C:\mysql\ directory, created a "my.ini" file using one of the samples and moved it into the "C:\windows\" directory. When I command prompt at the C:\mysql\bin\ directory "mysql" I get the error: "ERROR 2003 (HY000) can't connect to mysql server on 'localhost' 10061". What should I check? I just wanted to learn how to configure it manually so I didn't use the .msi. Thanks!
Searching array for partial 'exact' match
in PHP Coding Help
Posted
Yes, I tested my code. I am sorry, I had just added in the else statement for this post, as I have it working correctly as this:
It only needs to find one item, as the $keyword is a unique identifier. But you are right I should return false to the caller. Which is :