pcw Posted February 19, 2009 Share Posted February 19, 2009 Hi, just trying to translate this line from perl to php. Got half of it done, but cant work out the php equivalent for join and grep, and what order it all goes in. $out .= join $v2, grep { $_ != "" } split('/\#/', $v1); Quote Link to comment https://forums.phpfreaks.com/topic/146008-solved-join-and-grep-error/ Share on other sites More sharing options...
sasa Posted February 19, 2009 Share Posted February 19, 2009 try $out .= implode($v2, preg_split('/\#/', $v1, -1, PREG_SPLIT_NO_EMPTY)); Quote Link to comment https://forums.phpfreaks.com/topic/146008-solved-join-and-grep-error/#findComment-766550 Share on other sites More sharing options...
pcw Posted February 20, 2009 Author Share Posted February 20, 2009 Can anyone tell me what I have done wrong with this string? I keep getting the following error: Parse error: parse error, unexpected T_VARIABLE in sb.php on line 435 When i do a syntax check. $out .= join( "$v1 ", map ("<a href=sb.php?action=display&login=$_&session={$input['session']}>$_</a>") $favorites); Quote Link to comment https://forums.phpfreaks.com/topic/146008-solved-join-and-grep-error/#findComment-767012 Share on other sites More sharing options...
sasa Posted February 20, 2009 Share Posted February 20, 2009 $out .= join( "$v1 ", map ("<a href=sb.php?action=display&login=$_&session={$input['session']}>$_</a>", $favorites)); i'm not perl expert Quote Link to comment https://forums.phpfreaks.com/topic/146008-solved-join-and-grep-error/#findComment-767037 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.