Note that there are some explanatory texts on larger screens.

plurals
  1. POArray placeholders
    text
    copied!<p>I’ve got an array where PLACEHOLDER is a placeholder for the variable $value that I get later in the code:</p> <pre><code>$names = array( "&lt;a href='http://skyler.com' title='PLACEHOLDER'&gt;Skyler&lt;/a&gt;", "&lt;a href='http://jesse.com' title='PLACEHOLDER'&gt;Jesse&lt;/a&gt;", "&lt;a href='http://walter.com' title='PLACEHOLDER'&gt;Walter&lt;/a&gt;", "&lt;a href='http://skyler.com' title='PLACEHOLDER'&gt;Skyler&lt;/a&gt;", "&lt;a href='http://hank.com' title='PLACEHOLDER'&gt;Hank&lt;/a&gt;", "&lt;a href='http://marie.com' title='PLACEHOLDER'&gt;Marie&lt;/a&gt;", "&lt;a href='http://walter.com' title='PLACEHOLDER'&gt;Walter&lt;/a&gt;", "&lt;a href='http://walter.com' title='PLACEHOLDER'&gt;Walter&lt;/a&gt;", "&lt;a href='http://jesse.com' title='PLACEHOLDER'&gt;Jesse&lt;/a&gt;", ); </code></pre> <p>To check how often an equal value is in my array, I count them with <code>array_count_values</code>.</p> <pre><code>$count = array_count_values($names); foreach ($count as $key =&gt; $value) { echo $value . ' – ' . $key . '&lt;br /&gt;'; } </code></pre> <p>So I get something like this:</p> <pre><code>3 – &lt;a href='http:/walter.com' title='PLACEHOLDER'&gt;Walter&lt;/a&gt; 2 – &lt;a href='http://jesse.com' title='PLACEHOLDER'&gt;Jesse&lt;/a&gt; 2 – &lt;a href='http://skyler.com' title='PLACEHOLDER'&gt;Skyler&lt;/a&gt; 1 – &lt;a href='http://hank.com' title='PLACEHOLDER'&gt;Hank&lt;/a&gt; 1 – &lt;a href='http://marie.com' title='PLACEHOLDER'&gt;Marie&lt;/a&gt; </code></pre> <p>Now I’d PLACEHOLDER be replaced by $value, so I get the number as title tag of the link.</p>
 

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