Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    Regular Coder Coastal Web's Avatar
    Join Date
    Oct 2004
    Posts
    225
    Thanks
    12
    Thanked 3 Times in 3 Posts

    Question Which is faster strstr or substr?

    Hi guys, l was just wondering which of these two would be a quicker, substr or strstr? I've got a function that runs through about 20 different checks similar to the one below and l wanted to know which method would be the most optimized?

    Code:
    if(!strstr($result[0], '<span'))
    or
    Code:
    if(substr($result[0], 0, 5 ) != '<span')

  • #2
    Regular Coder
    Join Date
    Apr 2007
    Posts
    295
    Thanks
    0
    Thanked 19 Times in 19 Posts
    If you only want to check if one string occurs inside another, strpos()


  •  

    Tags for this Thread

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •