473,396 Members | 2,093 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

remove odd data from array

guys plz help,

i have an array(52,51,52)
here i want to insert first & last elements into DB, not second one does not follows the series

another array (52,52,53)
in this case insert first 2 elements into DB since last element does not follow the series.

how is this possible?
Apr 11 '12 #1
3 2033
Marknut
42
I'm not 100% sure what kind of patterns you may want to accept/deny, but you might try array_count_values: http://php.net/manual/en/function.ar...unt-values.php.
Apr 11 '12 #2
Expand|Select|Wrap|Line Numbers
  1. $ary = array(12,13,14,12,12,14,16,15,17,12,16,13,14,13);
  2.  
  3. $ar_count = count($ary);
  4.  
  5. for($a=0;$a<$ar_count;$a++)
  6. {
  7.     if($ary[$a]%2 ==  0)
  8.      {
  9.           $vl = $ary[$a];
  10.          $qry = "insert into table_name values($vl)";
  11.           $query = mysql_query($qry) or die(mysql_error());
  12.      }
  13.  
  14. }
Try It............

Bharat Parmar(Bharat383)
Apr 14 '12 #3
Dormilich
8,658 Expert Mod 8TB
I recommend array_filter().
Apr 16 '12 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

8
by: Jason Heyes | last post by:
If s is a std::string, does &s refer to the contiguous block of characters representing s?
1
by: Sluggoman | last post by:
Hi all, Am floundering through a course in which C was not a pre-req, but the assignment is in C - If someone could point out where I am going way off the rails, I'd apprecciate it. Please be...
5
by: lazypig06 | last post by:
Hi ! I am a PHP beginner. I hope somebody can help me with this problem that I've been having. I've been trying to clean up junk data that I have at the begining and ending of an xml file....
1
by: Kathy | last post by:
Hi: Can any one please help me out with how to remove data control from the form. I create a form with sub form too and it shows 2 controls and i want to hide/remove the subform control form the...
12
by: geerrxin | last post by:
Hi, I have a need to manipulate a large matrix, say, A(N,N) (of real) 8GB which can't fit in physical memory (2 BG). But the nature of computation requires the operation on only a portion of...
0
by: mwenz | last post by:
I am trying to update an Access table using OLEDB in VB.Net 2005. I can add rows but I cannot update them. Code to instantiate the Access database and table... Dim conn As New...
1
by: keith katthy | last post by:
Is it true I do like below, if I want to all data array? and the ouput is 2. How to know which array that computer take? #include <iostream> #include <conio.h> #include <cstdlib> #include...
3
by: wesley1970 | last post by:
<?php $a = array(1,2,3,4,5); $b = array(1,2,3,4,5,6,7,8); echo array_intersect($a, $b); ?> array_intersect should return the numbers of items intersect in 2 arrays. In this case, it...
0
by: ganeshvkl | last post by:
hi my requirement is create control arrays at run time that i achived but i couldn't remove control array object at run time visual Basic 6.0 i attached this code Private Sub...
12
by: Aditya sant | last post by:
Am spliting file string into array by using fgets(),and explode() On other hand am taking string from user,and again spliting it into array now I have 2 array when I compare 2 arrays by using...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.