Note that there are some explanatory texts on larger screens.

plurals
  1. POfind and replace country from string
    primarykey
    data
    text
    <p>I have an array of <strong>countries</strong> the key is the country code, the value is the country name, now i have a string, which is posted by users, i want to find if the string has country in it n replace it with </p> <pre><code>&lt;span class="country"&gt;$1&lt;/span&gt; </code></pre> <p>to make it even clearer : let's say i have this text : </p> <pre><code>Canada is a cold place </code></pre> <p>i want it to be :</p> <pre><code>&lt;span class="country"&gt;canada&lt;/span&gt; is a cold place </code></pre> <p>where i use my countries array to find and repalce.</p> <p>the reason behind this is i want to use the microformats, so i need to extract specific text from a string.</p> <p>i had similar preg_replaces code </p> <pre><code>$style = array( '/\[b\](.*)?\[\/b\]/isU' =&gt; '&lt;b&gt;$1&lt;/b&gt;', '/\[i\](.*)?\[\/i\]/isU' =&gt; '&lt;i&gt;$1&lt;/i&gt;', '/\[u\](.*)?\[\/u\]/isU' =&gt; '&lt;u&gt;$1&lt;/u&gt;', '/\[em\](.*)?\[\/em\]/isU' =&gt; '&lt;em&gt;$1&lt;/em&gt;', '/\[li\](.*)?\[\/li\]/isU' =&gt; '&lt;li&gt;$1&lt;/li&gt;', '/\[code\](.*)?\[\/code\]/isU' =&gt; '&lt;div class="tx_code"&gt;$1&lt;/div&gt;', '/\[q\](.*)?\[\/q\]/isU' =&gt; '&lt;q&gt;$1&lt;/q&gt;', '/[\r\n]{3}+/' =&gt; "\n" ); $text = preg_replace(array_keys($style),array_values($style),$text); </code></pre> <p>which works, i need something like that.</p> <blockquote> <blockquote> <p>Keep in mind, that it should not be case sensitive, some users may post canada or Canada</p> </blockquote> </blockquote> <p>thanks</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload