开发者

PHP/Smarty giving 'Array' instead of correct value?

开发者 https://www.devze.com 2023-01-23 23:32 出处:网络
Here is my code, f开发者_如何学运维rom the search results page: {if $listing.SalaryType!=\'\'&& $listing.Salary!=\'\'}<dt>Salary:</dt>

Here is my code, f开发者_如何学运维rom the search results page:

{if $listing.SalaryType!=''&& $listing.Salary!=''}<dt>Salary:</dt>
<dd>{$listing.Salary} {$listing.SalaryType}</dd>{/if}

Which gives this output:

PHP/Smarty giving 'Array' instead of correct value?

It says 'Array' instead of the correct value. Any idea where I can start looking to solve this problem? Where is the 'Array' coming from?

Here is some more information. On the job details page, this code:

<div class="smallListingInfo"><strong>[[FormFieldCaptions!Salary]]:</strong> {display property=Salary} [[$listing.SalaryType]]</div>

Gives this output:

PHP/Smarty giving 'Array' instead of correct value?

You can see the salary value works in this instance, how is that different?

Using the smarty debug console I got the following:

Title => Services Senior Manager
EmploymentType => Contractor
JobCategory => Accounting,Admin-Clerical
Occupations => empty
Country => United States
Salary => Array (5)
  add_parameter => 2
  value => 30000
  currency_sign => £
  course => 1
  currency_code => USD
State => California
SalaryType => per month
City => Los Angeles

How do I get the value to show instead of 'Array'?


$listing.Salary seems to be an Array.

Insert {debug} in your HTML code for dumping the debug console wich shows you the assigned variables.

Search for "debug" in the Smarty documentation (sorry, i can't post links here right now)

How to access elements of arrays in Smarty can also be found in the docs, just search for "variables"


It means the {$listing.Salary} value is an array instead of the value you expect. When PHP is asked to treat an array as a string, it'll use the value "Array". Fix your data structures and/or your template to use the right value.

$foo = array();
echo $foo; // echoes "Array"


{$listing.Salary} is an array.

In the PHP code, the object/array you pass to the template : 'Salary' index or attribute should return an integer and not an array.

0

精彩评论

暂无评论...
验证码 换一张
取 消