Search Results

Search found 1 results on 1 pages for 'oaziz'.

Page 1/1 | 1 

  • How can I write this in a shorter way?

    - by oaziz
    This code repeats itself. How can I make it shorter? Maybe by using anonymous function or something? foreach ($value as $wrong) { if (starts_with($wrong, '%') and ends_with($wrong, '%')) { $wrong = trim($wrong, '%'); if (contains($address, $wrong)) { $corrected_address = str_replace($wrong, $key, $address); break; } } else { $wrong = trim($wrong, '%'); if (ends_with($address, $wrong)) { $corrected_address = str_replace($wrong, $key, $address); break; } } } Thanks.

    Read the article

1