Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3980396
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T05:17:09+00:00 2026-05-20T05:17:09+00:00

I’m trying to take two lines of code from an elseif statement and create

  • 0

I’m trying to take two lines of code from an elseif statement and create a function that returns the parameters back to the parent function. It’s a simple card game that searches my $Cards array for a three of a kind. Here’s the original code:

elseif(count($Cards) == 3) {
            $CardsNotOfValue = $this->_getCardsNotOfFaceValue($faceValue, $CardsGroupedByValues);
            list($Kicker1, $Kicker2) = $this->_getSortedCards($CardsNotOfValue);
            return new ThreeOfAKind(array_merge($Cards, array($Kicker1, $Kicker2)));
        }

Thus far, my code looks like this:

function { if (count($Cards) == 3) {
            **LINE 36** $Kicker = $this->kickerCards($faceValue, $CardsGroupedByValues); }
**LINE 55** public function kickerCards(array $kickers)
{
    $CardsNotOfValue = $this->_getCardsNotOfFaceValue($faceValue, $CardsGroupedByValues);
    return $this->_getSortedCards($CardsNotOfValue);
}

When I try to execute a four of a kind, I get the following error (I tried to highlight the lines in question above):

PHP Catchable fatal error: Argument 1 passed to BestHandIdentifier::kickerCards() must be an array, integer given, called in /home/dev/parameter2/BestHandIdentifier.php on line 36 and defined in /home/dev/parameter2/BestHandIdentifier.php on line 55

I’m having a bit of trouble understanding how to create ($faceValue, $CardsGroupedByValues) and pass an array for my new function to evaluate. Have I gone too far in the wrong direction to begin with?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-20T05:17:09+00:00Added an answer on May 20, 2026 at 5:17 am

    Your function definition is:

    public function kickerCards(array $kickers);
    

    So $kickers must be an array…
    You are trying to call the function with:

    $this->kickerCards($faceValue, $CardsGroupedByValues);
    

    Passing two arguments, the $faceValue which is an integer, 2nd argument is an array.

    Your function definition should look like:

    public function kickerCards($faceValue, array $cards);
    

    If I could elaborate further, making some assumptions.

    My assumptions:

    1. The function take a face value and array of cards currently held
    2. The return of the function should be the cards in that array that do not match the face values.
    3. The Cards are an array with a value (and possibly suit) key. e.g.
      $twoOfHearts = array('value'=>2,'suit'=>'hearts');

    So here’s a possible implementation

    public function kickerCards($faceValue, array $cards) {
        $kickerCards = array();
        foreach($cards as $card) {
            if ($card['value'] != $faceValue)
                $kickerCards[] = $card;
        }
        return $kickerCards;
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to create an if statement in PHP that prevents a single post
Basically, what I'm trying to create is a page of div tags, each has
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
I'm trying to decode HTML entries from here NYTimes.com and I cannot figure out
I am currently running into a problem where an element is coming back from
I need a function that will clean a strings' special characters. I do NOT
I am trying to understand how to use SyndicationItem to display feed which is
link Im having trouble converting the html entites into html characters, (&# 8217;) i
That's pretty much it. I'm using Nokogiri to scrape a web page what has

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.