Jump to content

nephesh

Members
  • Posts

    22
  • Joined

  • Last visited

Everything posted by nephesh

  1. 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: 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; } } } } 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 : $index = array_search_partial($profilePaths, $userName); if($index){ $profileLink = "/".$profilePaths[$index].".html"; }
  2. 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; } } }
  3. Thanks for everyone's help with this! I've got it working perfectly!
  4. 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; } } } }
  5. 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.
  6. 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; } } }
  7. Ok, then how do I get the mysqld process started?
  8. 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!
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.