Message: trim() expects parameter 1 to be string, array give

Problems with the Windows version of XAMPP, questions, comments, and anything related.

Message: trim() expects parameter 1 to be string, array give

Postby mikealex2k12 » 06. December 2010 22:12

I installed a site engine and I get this error...

A PHP Error was encountered
Severity: Warning

Message: trim() expects parameter 1 to be string, array given

Filename: libraries/SmartyExtended.php

Line Number: 41

.....

Is there any way to make this message to away?
mikealex2k12
 
Posts: 9
Joined: 06. December 2010 22:06

Re: Message: trim() expects parameter 1 to be string, array

Postby WilliL » 06. December 2010 22:43

mikealex2k12 wrote:Message: trim() expects parameter 1 to be string, array given
Filename: libraries/SmartyExtended.php
Line Number: 41
Is there any way to make this message to away?

Yes, I think you have to debug your code and find the wrong code.
trim() is used for stings not for arrays.
If you are using a code like this "$_POST = array_map( 'trim', $_POST );" be sure that there is no array in $_POST
analyse $_POST['test'][0] and unset this variable before using trim().
Willi
WilliL
 
Posts: 660
Joined: 08. January 2010 10:54
Operating System: Win7Home Prem 64 SP1

Re: Message: trim() expects parameter 1 to be string, array

Postby Altrea » 06. December 2010 22:46

sure. Use the trim function in the right way.

wrong way
Code: Select all
<?php
$output = array( ' foo', ' bar ', 'baz ' );
$cleanoutput = trim( $output );


right way (single vars)
Code: Select all
<?php
$output = ' foo';
$cleanoutput = trim( $output );


right way (arrays)
Code: Select all
<?php
$output = array( ' foo', ' bar ', 'baz ' );
$cleanoutput = array();
foreach( $output as $value ) {
    $cleanoutput[] = trim( $value );
}
We don't provide any support via personal channels like PM, email, Skype, TeamViewer!

It's like porn for programmers 8)
User avatar
Altrea
AF Moderator
 
Posts: 11935
Joined: 17. August 2009 13:05
XAMPP version: several
Operating System: Windows 11 Pro x64


Return to XAMPP for Windows

Who is online

Users browsing this forum: No registered users and 125 guests