On 10/14/2006, "Nick" <[EMAIL PROTECTED]> wrote:

>--- In [email protected], "Mike Franks" <[EMAIL PROTECTED]> wrote:
>
>> 
>> Nick - what is the purpose of assigning a value to $val within this
>> foreach(), when the foreach is initializing a new $val within itself on
>> each iteration?
>> 
>> I believe you'll have much greater success if you use a different
>> variable on the left side of those three assignments.
>> 
>> hth,
>> Mike
>>
>
>Mike, I don't really follow you here... Do you mean to use a different
>variable name and then only reassign itself if a change is made? Like
>this:
>
>foreach ($outarr as $val) {
>   if(strpos($val, "http://"; ) === 0){
>      $a = '<a href="' . $val . '">' . $val . '</a>';
>   }elseif(strpos( $val,"ftp: //") === 0){
>      $a = '<a href="' . $val . '">' . $val . '</a>';
>   }else{
>      //do nothing
>   }
>
>   if ($a != $val){
>      $val = $a;
>   }
>}
>
>Thanks,
>-Nick
>
>

Actually, what I was trying do say (and didn't say very well) is that I
don't see what you're actually trying to accomplish with your
foreach() loop.

Unless you *use* the result of each iteration through the loop within the
body of the loop (print it, store it to some other structure, etc.), all
you're really doing is assigning $val (or $a, in your modified example)
based on the *last* element in your array.

Mike

P.S. I believe Pete correctly identified the cause of your error message.


Community email addresses:
  Post message: [email protected]
  Subscribe:    [EMAIL PROTECTED]
  Unsubscribe:  [EMAIL PROTECTED]
  List owner:   [EMAIL PROTECTED]

Shortcut URL to this page:
  http://groups.yahoo.com/group/php-list 
Yahoo! Groups Links

<*> To visit your group on the web, go to:
    http://groups.yahoo.com/group/php-list/

<*> Your email settings:
    Individual Email | Traditional

<*> To change settings online go to:
    http://groups.yahoo.com/group/php-list/join
    (Yahoo! ID required)

<*> To change settings via email:
    mailto:[EMAIL PROTECTED] 
    mailto:[EMAIL PROTECTED]

<*> To unsubscribe from this group, send an email to:
    [EMAIL PROTECTED]

<*> Your use of Yahoo! Groups is subject to:
    http://docs.yahoo.com/info/terms/
 


Reply via email to