Skip to content

Instantly share code, notes, and snippets.

/*****
Code by: Elron
Initialy coded for: https://elrons.co.il/
Learn more about this code here: https://elrons.co.il/pagination/
*****/
nav.navigation.pagination {
div.nav-links {
text-align: center;
display: flex;
justify-content: center;
@elron
elron / contains.function.php
Created August 26, 2020 17:50
PHP function to check if a string contains a specific word(s)
function contains($str, array $arr) {
// Works in Hebrew and any other unicode characters
// Thanks https://medium.com/@shiba1014/regex-word-boundaries-with-unicode-207794f6e7ed
// Thanks https://www.phpliveregex.com/
if (preg_match('/(?<=[\s,.:;"\']|^)' . $word . '(?=[\s,.:;"\']|$)/', $str)) return true;
}
// Works in English
contains('hello how are you', ['are']); // true
<?php
/**
* Wrap last word with span
* @author: Elron
* https://stackoverflow.com/questions/18612872/get-the-last-word-of-a-string
*/
function wrap_last_word($string) {
// Breaks string to pieces
$pieces = explode(" ", $string);