FUDforum
Fast Uncompromising Discussions. FUDforum will get your users talking.

Home » Imported messages » comp.lang.php » array filtering question
Show: Today's Messages :: Polls :: Message Navigator
Return to the default flat view Create a new topic Submit Reply
Re: array filtering question [message #178186 is a reply to message #178184] Mon, 21 May 2012 15:18 Go to previous messageGo to previous message
bill is currently offline  bill
Messages: 310
Registered: October 2010
Karma:
Senior Member
On 5/21/2012 10:46 AM, Jerry Stuckle wrote:
> On 5/21/2012 10:22 AM, bill wrote:
>> I have a POST array with about 200 elements.
>> There MAY be one or more key elements that start with deleteF~
>> (for example deleteF~EAP, deleteF~Lowfee)
>>
>> What I want to know is if any array element begins with deleteF~
>>
>> I looked at array_keys, array_filter and others, but they seem
>> to all
>> match the whole key string.
>>
>> I can process the whole array myself, but I am hoping that with
>> all the
>> array functions there might be one.
>>
>> It would be nice if I could apply an array function and get
>> back an
>> array with just those keys. (they are checkboxes so the value
>> is always
>> "on", just their presence is enough information.)
>>
>> bill
>
> There isn't a real easy way to do this other than going through
> the whole array.
>
> However, I think your design could be improved. Why have multiple
> checkboxes with different names and the same value? Why not have
> all the checkboxes with the same name and different values?
>
> It would make processing much easier.
>

Thanks Jerry,

There are major deletes (the ones I mentioned) and minor deletes
AND about another 200 fields with values. This is how it
appeared in the feeble thing I use for a brain.

It only took me 4 lines to create the array with the keys I need
in it. The key encodes the item to delete: apply substr to it
and I have the items to delete and the class of item they
represent (which leads to the file name...)

I suppose I could do it the way you suggested, but then I'd need
to get my mind wrapped around that design and this part of the
project is 90% complete (which of course means it is 90% incomplete).

Thanks for the reasurance.

bill
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: Latest project
Next Topic: array_walk always passing 0 as the parameter
Goto Forum:
  

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ]

Current Time: Wed Dec 18 21:48:15 GMT 2024

Total time taken to generate the page: 0.23616 seconds