[wp-trac] [WordPress Trac] #19347: Ugly alert: false !== strpos( $which_one_was_needle, $this_one )

WordPress Trac wp-trac at lists.automattic.com
Thu Nov 24 11:56:26 UTC 2011


#19347: Ugly alert: false !== strpos( $which_one_was_needle, $this_one )
---------------------------------------------+-----------------------------
 Reporter:  nbachiyski                       |       Owner:  westi
     Type:  enhancement                      |      Status:  reviewing
 Priority:  normal                           |   Milestone:  Future Release
Component:  General                          |     Version:
 Severity:  normal                           |  Resolution:
 Keywords:  has-patch westi-likes 3.4-early  |
---------------------------------------------+-----------------------------

Comment (by daniloercoli):

 {{{
 strpos( $one_string, $other_string ) == ( strlen( $one_string ) - strlen(
 $other_string )
 }}}

 The code above doesn't work if there are multiple occurrences of
 '$other_string'  in '$one_string'. I think the best way to test the
 'EndWith' condition is using something like the code below:

 {{{
 strpos(  strrev( $one_string  ), strrev( $other_string  )  ) ===  0
 }}}

-- 
Ticket URL: <http://core.trac.wordpress.org/ticket/19347#comment:5>
WordPress Trac <http://core.trac.wordpress.org/>
WordPress blogging software


More information about the wp-trac mailing list