× The internal search function is temporarily non-functional. The current search engine is no longer viable and we are researching alternatives.
As a stop gap measure, we are using Google's custom search engine service.
If you know of an easy to use, open source, search engine ... please contact support@midrange.com.



Use array_search, which returns the value of the first match ...

http://www.php.net/manual/en/function.array-search.php
http://forums.zend.com/viewtopic.php?f=63&t=1407

---------
Tom Jedrzejewicz
tomjedrz@xxxxxxxxxxxxxx



On Wed, Jul 7, 2010 at 8:18 AM, Shannon ODonnell
<sodonnell@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote:
So this is driving me crazy trying to figure out the syntax.



Very probably I'm overthinking it and making it harder than it needs to be
but.



In RPG, it's really easy to find an element in an array based on some value,
and then to update that array element at the found index.



ÂIf   ÂmyArray(idx) = "T"

  Eval  myArray(idx) = "F";

Endif;





But how do I do that in PHP?



I can search for a value in an array using Âin_array:



 $found = in_array($myValueToSearchFor, $theArrayToSearch)

ÂIf($found)

Â{

Â}





But I can't quite figure out, once I know that my value is in that array, of
how to update that particular array element Âand/or add a new element to
that array at that index.







Shannon O'Donnell





--
This is the PC Technical Discussion for iSeries Users (PcTech) mailing list
To post a message email: PcTech@xxxxxxxxxxxx
To subscribe, unsubscribe, or change list options,
visit: http://lists.midrange.com/mailman/listinfo/pctech
or email: PcTech-request@xxxxxxxxxxxx
Before posting, please take a moment to review the archives
at http://archive.midrange.com/pctech.


As an Amazon Associate we earn from qualifying purchases.

This thread ...

Follow-Ups:
Replies:

Follow On AppleNews
Return to Archive home page | Return to MIDRANGE.COM home page

This mailing list archive is Copyright 1997-2024 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].

Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.