Nov 15, 2013; 16:40
Paul Melia
Removing Empty Entries in An Array
Hi Lassoers,
I have a situation where I am taking data from MySQL and inserting it into an array.
The number of fields with data in them varies from record to record (could be anywhere between 1 to 16 fields with data), so I am trying to loop through the array and remove any entries that are empty.
Here is the code I have created so far...
var(epcount=array())
$epcount->insert(field:'ep1')
$epcount->insert(field:'ep2')
$epcount->insert(field:'ep3')
$epcount->insert(field:'ep4')
$epcount->insert(field:'ep5')
$epcount->insert(field:'ep6')
$epcount->insert(field:'ep7')
$epcount->insert(field:'ep8')
$epcount->insert(field:'ep9')
$epcount->insert(field:'ep10')
$epcount->insert(field:'ep11')
$epcount->insert(field:'ep12')
$epcount->insert(field:'ep13')
$epcount->insert(field:'ep14')
$epcount->insert(field:'ep15')
$epcount->insert(field:'ep16')
local(eploopcount = 0)
with i in $epcount do {
#eploopcount += 1
if($epcount->get(#eploopcount)=='')
$epcount->remove(#eploopcount)
/if
}
The code is successfully inserting the data into the array but it is also creating empty array entries.
When I output the array $epcount, this is what I get:
array(Chi Awakens, Chi Goes Out, Chi Learns, Chi Goes on Errands, , , , , , , , )
I checked the data in MySQL and there isn't anything different between the definition of fields. Empty fields are simply empty.
What am I missing?
I appreciate any shove in the right direction.
Thanks,
Paul
#############################################################
This message is sent to you because you are subscribed to
the mailing list Lasso
Lasso@lists.lassosoft.com
To unsubscribe, E-mail to: <Lasso-unsubscribe@lists.lassosoft.com>
Send administrative queries to <Lasso-request@lists.lassosoft.com>
Nov 15, 2013; 23:01
Jolle Carlestam
Re: Removing Empty Entries in An Array
Nov 15, 2013; 17:13
Paul Melia
Re: Removing Empty Entries in An Array