Note that there are some explanatory texts on larger screens.

plurals
  1. POCan you compare an array of strings in PHP and if there are two that are the same it will only return it once?
    primarykey
    data
    text
    <p>Here is the script I am running and I would like if there are 2 strings that the same to only display one string and not both. I dont know where to add the array_unique() I have added it to my script but it doesnt seem to work properlly, instead it is taking out all the strings with the same value Here is the script I am running and I would like if there are 2 strings that the same to only display one string and not both<br> <pre><code>//Get slider data from theme options $company1 = $data['md_media_company_img1']; $company2 = $data['md_media_company_img2']; $company3 = $data['md_media_company_img3']; $company4 = $data['md_media_company_img4']; $company5 = $data['md_media_company_img5']; $company6 = $data['md_media_company_img6']; $company7 = $data['md_media_company_img7']; $company8 = $data['md_media_company_img8']; $company9 = $data['md_media_company_img9']; $company10 = $data['md_media_company_img10']; $company11 = $data['md_media_company_img11']; $company12 = $data['md_media_company_img12']; /*Slides Array*/ $company_name = array( 'company1' =&gt; array( 'name' =&gt; $company1, ), 'company2' =&gt; array( 'name' =&gt; $company2, ), 'company3' =&gt; array( 'name' =&gt; $company3, ), 'company4' =&gt; array( 'name' =&gt; $company4, ), 'company5' =&gt; array( 'name' =&gt; $company5, ), 'company6' =&gt; array( 'name' =&gt; $company6, ), 'company7' =&gt; array( 'name' =&gt; $company7, ), 'company8' =&gt; array( 'name' =&gt; $company8, ), 'company9' =&gt; array( 'name' =&gt; $company9, ), 'company10' =&gt; array( 'name' =&gt; $company10, ), 'company11' =&gt; array( 'name' =&gt; $company11, ), 'company12' =&gt; array( 'name' =&gt; $company12, ) ); /*check if exist slide*/ $check_exist_company = 0; $result = array_unique($company_name); foreach($result as $company =&gt; $value) { if (!empty ($value['name'])){ $check_exist_company = 1; } } </code></pre> <p>?> </p> <pre><code> &lt;?php if($check_exist_company == 1) {// check if any slide image added in theme option, return custom slide?&gt; &lt;?php $i = 1; ?&gt; &lt;?php foreach($company_name as $company =&gt; $value) { if (!empty ($value['name'])) {?&gt; &lt;li&gt;&lt;a class="nivoLink4" rel="&lt;?php echo $i;?&gt;" href="#"&gt;&lt;?php echo $value['name'];?&gt;&lt;/a&gt;&lt;/li&gt; &lt;?php ++$i ?&gt; &lt;?php } ?&gt; &lt;?php }?&gt; &lt;?php } ?&gt; &lt;!--/slider--&gt; </code></pre>
    singulars
    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.
    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