PHP: How do I check the contents of an array for my string? -


I have a string which is coming from my database table, say $ needle. If the needle is not in my array, then I want to add it to my array.

If it is in my array, it is only in two times, even if I want to add it to my array (it will be three times maximum)

To see it Is the $ needle in my $ gear array, do I need a loop through the array with the strokes (or is there a quick method)?

The table has many needles, so I'm starting looping through the selection result.

This is the schematic of what I am trying to do ...

  $ haystack = array (); While ($ line = mysql_fetch_assoc ($ result)) {$ needle = $ line ['data']; $ Num = no $ $ in needle $ hejstack $ / $ haystack is an array if ($ num <3) {$$ haystack [] = $ needle; // hope that it connects the needle}} // end time Get the next needle? Do anyone know how I should do this: 

$ num = no $ needle $ hansstack

Thank you

You first use the value for each value to build the map , And after that only the value can increase if the value was calculated in the map & lt; 3, For example:

  $ original_values_count = array_count_values ​​($ value); Forex currency ($ value as $ value) if ($ parent_man value_value [$ value] & lt; 3) $ value [] = $ value; Can not be completely avoided in the form of a loop, I can say that it is a good idea to choose the option to use the native PHP function in terms of speed compared to looping manually, all values ​​manually. 


Comments

Popular posts from this blog

oracle - The fastest way to check if some records in a database table? -

php - multilevel menu with multilevel array -

jQuery UI: Datepicker month format -