Re: Syntax Snag need extra eyes

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Thu, Jul 16, 2009 at 12:43 PM, Andrew Ballard<aballard@xxxxxxxxx> wrote:
> On Thu, Jul 16, 2009 at 12:35 PM, Jim Lucas <lists@xxxxxxxxx> wrote:
>>
>> Andrew Ballard wrote:
>> > On Thu, Jul 16, 2009 at 12:25 PM, Jim Lucas <lists@xxxxxxxxx> wrote:
> [snip]
>> >> Also, this is the wrong way to use printf().  Please go read the manual
>> >> page for this function.
>> >>
>> >> Try:
>> >>
>> >> printf(
>> >>        '<a href="view.php?name=%s"><b>%s</b><br />%s<br /><br /></a>',
>> >>        $row['name'],
>> >>        $row['name'],
>> >>        $row['address']
>> >> );
>> >>
>> >> This is the correct way to use printf()
>> >>
>> >>
>> >>
>> > I like this, just because I don't need to repeat $row['name'] (but it is the
>> > same thing):
>> >
>> > printf(
>> >        '<a href="view.php?name=%1$s"><b>%1$s</b><br />%2$s<br /><br /></a>',
>> >        $row['name'],
>> >        $row['address']
>> > );
>> >
>> > Andrew
>> >
>>
>>
>> I was wondering if that was possible.
>>
>> Thanks for the tip.
>>
>> Jim Lucas
>>
>
> That's what I like about this list. I wasn't totally sure it would
> work myself, but I was pretty sure it would, and this was another one
> of those posts that provided just enough prompting for me to actually
> pop the code into Zend Studio where I could test it pretty quickly.
> :-)
>
> Andrew
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>

another option is to wrap the array elements in curly braces

printf('<a
href="view.php?name={$row['name']}"><b>%s</b><br>%s</br><br></a>',$row['name']
,$row['address']);

-- 

Bastien

Cat, the other other white meat

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux