Please Help With An Array Problem - Programming - Nairaland
Nairaland Forum › Science/Technology › Programming › Please Help With An Array Problem (1364 Views)
| Please Help With An Array Problem by CRAZYMADMAN(op): 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(op): 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(op): 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 |
| Re: Please Help With An Array Problem by CRAZYMADMAN(op): 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(op): 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(op): 10:07am On Dec 15, 2014 |
JackOfAllTrades:it worked perfectly with just a little modification. thanks |
| Re: Please Help With An Array Problem by CRAZYMADMAN(op): 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. |
Php Array Problem [SOLVED] • Simple Array Problem In Php • Converting Picture To Byte Array(blob) And Back To Picture • 2 • 3 • 4
Having A Challenge In C# • Excel Macro VBA Programming. • 'if' By Davido - Javascript Version
