0

As I am not very good with explaining things, I want to start with the code below:

     public function meta ( ) {
            $keywords_arr = $this->keywords();  
           /*
            echo "<pre>"; print_r($keywords_arr);die;
            gives following output:
            Array
            (
               [0] => f
               [1] => Business
               [2] => AP Online Top Business Short Headlines
               [3] => AP Online
            )

           */              

            $focuskw  = is_array($keywords_arr[0]) ? $keywords_arr[0] : null;
            return array(
                    '_yoast_wpseo_focuskw' => $focuskw          
            );
}

So now my question, is there any way i can eliminate the useless items from keyword array.

So that I can get some meaningful word that I can set as focused keyword.

In this case the first item "f" (but it can be any item) and i cannot set "F" as focused keyword.

So How to eliminate such meaningless items from array without adding complexity(i.e probably not running loop). I am not sure if it is possible.

I hope I am a bit more clear now.

Thank you

SD433
  • 143
  • 11
  • 2
    You’ll need to properly define what exactly makes an item “useless” first. – CBroe Jan 16 '18 at 16:08
  • Why not use a loop and `unset` what you don't need? – Kisaragi Jan 16 '18 at 16:08
  • I think you are looking for https://secure.php.net/manual/en/function.array-shift.php (in your case). But try to use https://secure.php.net/manual/en/ref.array.php in general – Edwin Jan 16 '18 at 16:09
  • Once you can answer @CBroe's question, you may use [array_search](http://php.net/manual/en/function.array-search.php) to match that criteria and remove it. – IsThisJavascript Jan 16 '18 at 16:10
  • Useless mean item with single character only for this case. I just want to check other options than running a loop. – SD433 Jan 16 '18 at 16:59
  • I have edited the question – SD433 Jan 16 '18 at 17:10

0 Answers0