Flipkart

Friday, September 28, 2012

Provide RegEx feature for array_key_exists function

Hi,

  Here is the function which can take the $key as a RegEx/String. This function checks whether the given string($string) is a Regular Expression or not. If yes, it will use preg_match() function else it will use array_key_exists()  function.

function preg_array_key_exists($filename, $array) {
    $available = false;  
    if (array_key_exists($filename, $
array))
    {
        $available = true;      
    }
    else
    {      
        $keys = array_keys($
array);
        foreach ($keys as $key) {        
            if (@preg_match($key, $filename) == 1) {  
              $available = true;          
          }      
        }
    }
    return $available;
}

13 comments:

  1. Encounter Chu Long before they hit kill, good distribution in advance each person is responsible cheap d3 gold for the area, in addition to this strange we will continue to read the article, you can interrupt the next.

    ReplyDelete
  2. Many people like to compare. Comparing what they have with what others don't, comparing what they are good at with what others are short at, so they can find the self-confidence. On the contrary, some other people like to compare what they do not have with what others are rich at, compare what they are short at with what others are good at, then they feel lost and disappointed all the time. It is not smart as you are the only one in the world. No one can be compared with you as you are all different. It is even worse to put your happiness on the basis of comparison with others. There are always someone who is doing better than you, and someone who is doing worse than you. These comparison means nothing as everything can be changed. Just like playing the World of Warcraft. You are having better skills and mounts at this time, it doesn't means that they can not be catched up. You can choose to buy wow gold, or just farm the gold by yourself. It is the way you choose to change that really matters.

    ReplyDelete
  3. Good article! Thank you so much for sharing this post. Your views truly open my mind. I will share it with other people.

    ReplyDelete
  4. Thank for your writing. I think this give more information which is very popular nowadays.

    ReplyDelete
  5. I agree with your conclusions and will eagerly look forward to your incoming updates. Just saying thanks will not just be adequate, for the wonderful clarity in your writing.It is imperative that we read blog post very carefully

    ReplyDelete
  6. Thanks a lot and keep sharing the information. Keep updating the information for all of us.

    ReplyDelete
  7. I visited your site & after visiting i found that it is very informational for everyone you have done really a great job

    ReplyDelete
  8. I am interested in the article. Thank so much. I hope to see more useful news from you.

    ReplyDelete
  9. This is my first time i visit here. I found so many entertaining stuff in your blog, especially its discussion. From the tons of comments on your articles, I guess I am not the only one having all the leisure here! Keep up the good work.

    ReplyDelete
  10. I am interested in the article. Thank so much. I hope to see more useful news from you.

    ReplyDelete
  11. I am glad to see your article. I like it so much. And I think everyone does.

    ReplyDelete
  12. I am so fascinated with the entire content of your site, from the material to the theme. I really had a great time reading and watching this post.

    ReplyDelete
  13. I enjoy reading your article/ blog; I find most of them to be thoughtful and interesting

    ReplyDelete