NYCPHP Meetup

NYPHP.org

[nycphp-talk] Any PHP users here also know TCL?

soazine@pop.erols.com soazine at pop.mail.rcn.net
Sat Jun 7 17:42:34 EDT 2003


Thanx for your solution.  Now I have to face another issue.  The "pollID
$pollID" elements that were joined together into one element in the same
list now have to be broken apart within the same list.  How do I do that
too?

Thanx
Phil

Original Message:
-----------------
From:  james at surgam.net
Date: Sat,  7 Jun 2003 14:14:35 -0400
To: talk at nyphp.org
Subject: Re: [nycphp-talk] Any PHP users here also know TCL?




"soazine at pop.erols.com" says:
> I could use a hand with a TCL-related problem I'm having on my site!
>
> I have a list as follows:
>
> id 1 pollID 1 question {How are you?} answerID 1 answer {I'm fine,
> thanx}
> id 2 pollID 1 question {How are you?} answerID 2 answer {OK} id 3
> pollID 1
> question {How are you?} answerID 3 answer {Leave me alone, life
> sucks!} id
> 4 pollID 2 question {Do you think there should be a TCL
> certification exam
> in Brainbench?} answerID 1 answer {Yes} id 5 pollID 2 question {Do
> you
> think there should be a TCL certification exam in Brainbench?}
> answerID 2
> answer {No}
>
>
> I am going to edit this list by doing a change to a part of the
> question/answer set in, say, pollID 2.  I want to them go to the
> first
> instance of "pollID 2" and not have to loop as this list can become
> extremely large (on my live site the XML file that this list is
> derived
> from has an id range that goes to 1000!).
>
> How then do I use [lsearch] based on this pattern? "pollID $pollID"?
> [lsearch] fails every combination I tried (returns -1), while
> [string
> first] finds it, however, the index is completely wrong for the list
> functions.
>
> Advice?

Your problem is that pollID and 2 are each elements of your list.  If
you want them to be treated as one element, you need to quote them.
lsearch only searches individual elements.  If you want to find the
particular element of the list that precedes the numeral "2", you'll
have to loop over the elements.  Perhaps you would be better off
quoting the two strings to create one element, e.g. "pollID 2", when
you create the list, instead of when you search it.


--- Unsubscribe at http://nyphp.org/list/ ---



--------------------------------------------------------------------
mail2web - Check your email from the web at
http://mail2web.com/ .






More information about the talk mailing list