Take the 2-minute tour ×
Stack Overflow is a question and answer site for professional and enthusiast programmers. It's 100% free, no registration required.

I'm using a method that takes an array of words and removes any that don't match the following:

return is_array( $var ) ? array_intersect( $var,
    array(
        'current_page_item',
        'current-menu-item',
        'current_page_parent',
        'current_page_ancestor',
        'current-menu-ancestor',
        'first',
        'last',
        'vertical',
        'horizontal'
    )
) : '';

How can I modify this so that I can include li(?:-[a-z_-]+)?? (Examples: li, li-align_left, li-magnify)

share|improve this question

1 Answer 1

up vote 3 down vote accepted

You could use array_filter to achieve this:

return is_array( $var ) ? array_filter($var, function($ele) {
  return preg_match('/li(?:-[a-z_-]+)?/', $ele);
}) : '';
share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.