Jump to content
deserty

Count specific value

Recommended Posts

Am un array de genul

$two=array("2", "3", "2", "1", "3");

Cu ce functie pot calcula de cate ori se afla valoare 2 in array ?

Nu stiu sigur daca chiar exista vre-o functie dar poti crea tu una.

function getNumber($valoare,$sir)
{
$contor=0;
for ($i=0;$i<count($sir);$i++)
{
if ($sir[$i]==$valoare)
{$contor++;}
}
return $contor;
}

Nu am probat dar trebuie sa mearga.

Ca sa apelezi folosesti getNumber("gica",$array);

Edited by Zatarra
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.



×
×
  • Create New...