PHP Array Sorting/Calculating

I'm creating a simple card game but stalled with the final function. Sorting the cards after a game.

I need help to sort out an array of card. Remove flush, same card ranks.

$cardleft= "2d,2c,2s,2h,3s,4s,4h,5s,7s,8s,10s,11s,12s";

I have to remove from an array the flush with more than 2 cards and 3 or 4 cards with the same ranks(trio or cuadro); if cuadro, check if one of them can use in the flush. The remaining is the final count of the cards.

In the example above I have to remove:




The remaining cards should be:


Some more details

The cards are already set in the array... all it needs is sorting out.

The goal of the game is to have the lowest possible value... zero would be the lowest.

Remove 3 or more flushes from the array.

Remove 3 or 4 same value from the array.

Cannot reuse a card. (if you use the card in a flush, you can't use it to get 3 of a kind with the same card)

Some cases:

example case 1:


returns lowest value = 1c,2c

example case 2:


returns lowest value = 1c,1d,

example case 3:


returns lowest value = 4d,4s

example case 4:


returns lowest value =0

example case 5:


returns lowest value = 0

The tricky part is WHERE to use a card when it is possible to use it either with flush or trio. It should be use where it would output the lowest possible card values to be left, see above cases.

Taidot: PHP

Näytä lisää: php array sorting, calculate array php, use case simple example, sort array c, lowest lowest, goal zero, creating use case, card game array, php array sort value, find array array php, php array flush, php array sort, calcular arrays php, php calculate array, calculator php arrays, php arrays calculator, php array report, calculate job experience using php, php array calculation, php array sort date, calculate values within arrays php, need help in 2d, calculating, output php, function check php

Tietoa työnantajasta:
( 1 arvostelu ) New Territory, Hong Kong

Projektin tunnus: #451175

Myönnetty käyttäjälle:


I'm an expert in game algorithmics, if that matters. I'll be able to write your function ( fully working ) in less than a day. Hope I'll hear from you. Cheers, MentallySafe

$50 USD 0 päivässä
(2 Arvostelua)

2 freelanceria on tarjonnut keskimäärin %project_bid_stats_avg_sub_26% %project_currencyDetails_sign_sub_27% tähän työhön


hello, I can give you the solution. I have 3+ years of experience in web development. thanks!

$30 USD 1 päivässä
(0 arvostelua)