Welcome, Guest: Register On Nairaland / LOGIN! / Trending / Recent / NewStats: 3,208,049 members, 8,001,261 topics. Date: Wednesday, 13 November 2024 at 07:47 AM |
Nairaland Forum / Science/Technology / Programming / Please Help With An Array Problem (1271 Views)
Php Array Problem [SOLVED] / Simple Array Problem In Php / Converting Picture To Byte Array(blob) And Back To Picture (2) (3) (4)
Please Help With An Array Problem by CRAZYMADMAN(m): 8:33pm On Dec 14, 2014 |
I am working on a web app that involves collecting data in arrays. Now I need to split the arrays in such a way that a variable holds the last array element of the array, while another holds the rest, so I run some database queries on it. Please guys, any idea on how to go about it? |
Re: Please Help With An Array Problem by Nobody: 8:35pm On Dec 14, 2014 |
ur user name and what u posted, I fear oooo. just passing!!!! |
Re: Please Help With An Array Problem by JackOfAllTrades: 9:07pm On Dec 14, 2014 |
CRAZYMADMAN:what language are you working with |
Re: Please Help With An Array Problem by CRAZYMADMAN(m): 9:08pm On Dec 14, 2014 |
afolag:what's wrong with that? abeg, programming is for everybody that have the interest |
Re: Please Help With An Array Problem by CRAZYMADMAN(m): 9:08pm On Dec 14, 2014 |
JackOfAllTrades: PHP |
Re: Please Help With An Array Problem by JackOfAllTrades: 9:25pm On Dec 14, 2014 |
CRAZYMADMAN:<?php $myArray = array('red','yellow','green','blue'); $array_len = count ( $myArray ); $last_element = $myArray[ $array_len - 1]; unset( $myArray[ $array_len - 1] ) ; // $myArray no longer holds blue check if it works not tested oo 2 Likes |
Re: Please Help With An Array Problem by CRAZYMADMAN(m): 9:37pm On Dec 14, 2014 |
JackOfAllTrades: thanks a lot for the help, but however I still need the last element because of the nature of the database query I need to run on the arrays |
Re: Please Help With An Array Problem by JackOfAllTrades: 9:42pm On Dec 14, 2014 |
CRAZYMADMAN:I don't get you please explain more! did u read my code @all |
Re: Please Help With An Array Problem by CRAZYMADMAN(m): 9:46pm On Dec 14, 2014 |
JackOfAllTrades: sorry I didn't read the unset part well. the logic is sound and should work. thanks a lot |
Re: Please Help With An Array Problem by JackOfAllTrades: 9:51pm On Dec 14, 2014 |
CRAZYMADMAN:OK test it then, you welcome man |
Re: Please Help With An Array Problem by CRAZYMADMAN(m): 10:07am On Dec 15, 2014 |
JackOfAllTrades: it worked perfectly with just a little modification. thanks 2 Likes |
Re: Please Help With An Array Problem by CRAZYMADMAN(m): 4:22pm On Jan 01, 2015 |
just came across a PHP function that does exactly this! it's called ARRAY_POP |
Re: Please Help With An Array Problem by bot101(m): 4:43pm On Jan 02, 2015 |
A Simple Array Pop Will Do. |
(1) (Reply)
Introduction To Python – Tutsplus / Help Me Solve This AJAX Problem. / Connecting Delta State Programmers
(Go Up)
Sections: politics (1) business autos (1) jobs (1) career education (1) romance computers phones travel sports fashion health religion celebs tv-movies music-radio literature webmasters programming techmarket Links: (1) (2) (3) (4) (5) (6) (7) (8) (9) (10) Nairaland - Copyright © 2005 - 2024 Oluwaseun Osewa. All rights reserved. See How To Advertise. 15 |