Jump to content

Leaderboard

Popular Content

Showing content with the highest reputation on 03/28/2022 in all areas

  1. str_replace takes an array of search string and a corresponding array of replacement strings, so... $source = ' {% snippet "header" %} yada yada {% setting "X" %} yada yada {% collection "stamps" %} blah blah {% snippet "footer" %} '; $html = str_replace( [ '{% snippet ', '{% collection ', '{% setting ', '%}' ], [ '<x-snippet name=', '<x-collection name=', '<x-setting name=', '/>' ], $source ); echo '<pre>' . htmlentities($html) . '</pre>'; Giving... <x-snippet name="header" /> yada yada <x-setting name="X" /> yada yada <x-collection name="stamps" /> blah blah <x-snippet name="footer" />
    1 point
  2. Try $html2 = str_replace( ['{% snippet ', '%}'], ['<x-snip name=', '/>'], $html);
    1 point
  3. Since you want to filter an array, I suggest array_filter() $times = [ '2021-06-02T19:40:00Z', '2021-06-03T02:10:00Z', '2021-06-03T01:10:00Z', '2021-06-02T23:05:00Z', '2021-06-02T23:05:00Z', '2021-06-02T23:07:00Z', '2021-06-02T23:20:00Z', '2021-06-02T18:20:00Z', '2021-06-03T00:10:00Z', '2021-06-03T00:40:00Z' ]; $d = new DateTime('23:59:59', new DateTimeZone('Z')); $newtimes = array_filter($times, function($v) use ($d) { return new DateTime($v) <= $d; });
    1 point
This leaderboard is set to New York/GMT-05:00
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.