KingOfHeart Posted October 24, 2010 Share Posted October 24, 2010 $out = wordwrap($data,400,"@"); $output = explode("@",$out, -1); By default a -1 no longer works properly for me so I need a similar method to get the same output. I made a game back then that reads the php file. So I could change the extension to .php4/.php5 (forget which one would work) the sockets will still link to the default .php file. So how can I fix this? Quote Link to comment https://forums.phpfreaks.com/topic/216720-explode-replacement-or-a-work-around/ Share on other sites More sharing options...
mentalist Posted October 24, 2010 Share Posted October 24, 2010 What do you mean it no longer works properly? If you get the whole array instead of all but one, then either use array_slice or iterate through to count-1. Quote Link to comment https://forums.phpfreaks.com/topic/216720-explode-replacement-or-a-work-around/#findComment-1125911 Share on other sites More sharing options...
KingOfHeart Posted October 24, 2010 Author Share Posted October 24, 2010 My host changed it's default php support. http://php.net/manual/en/function.explode.php Quote: 5.1.0 Support for negative limits was added 4.0.1 The limit parameter was added ************ By default the - limit does not work. Quote Link to comment https://forums.phpfreaks.com/topic/216720-explode-replacement-or-a-work-around/#findComment-1125918 Share on other sites More sharing options...
mentalist Posted October 24, 2010 Share Posted October 24, 2010 Yes, that looks normal, same as my manual... Sorry, I think you should explain what it did before. If 'limit' wasn't present (and no other third arg existed) then, just mimic using my previous answer. Otherwise please explain fully and clearly what results your getting and what you expected. Quote Link to comment https://forums.phpfreaks.com/topic/216720-explode-replacement-or-a-work-around/#findComment-1125930 Share on other sites More sharing options...
KingOfHeart Posted October 25, 2010 Author Share Posted October 25, 2010 explode returns nothing, that's what I'm saying. It's because of that -1. I want to get the same result but can't use a -1. So what do I do? Quote Link to comment https://forums.phpfreaks.com/topic/216720-explode-replacement-or-a-work-around/#findComment-1126011 Share on other sites More sharing options...
mentalist Posted October 25, 2010 Share Posted October 25, 2010 What version of PHP is running on your server? Are you 100% positive that the issue isn't with the input? When you say 'nothing', is that what is really happening, are you sure it's not an empty array? (if so re-read the manual!) Try isolating the issue... $out="here@there@where@lost"; $output = explode("@",$out, -1); Quote Link to comment https://forums.phpfreaks.com/topic/216720-explode-replacement-or-a-work-around/#findComment-1126110 Share on other sites More sharing options...
KingOfHeart Posted October 25, 2010 Author Share Posted October 25, 2010 It's the -1. I removed the -1 and it seems to work just fine. Told you it was the version issue. Quote Link to comment https://forums.phpfreaks.com/topic/216720-explode-replacement-or-a-work-around/#findComment-1126328 Share on other sites More sharing options...
Pikachu2000 Posted October 25, 2010 Share Posted October 25, 2010 If this was working, then stopped, that means your host downgraded PHP versions? Quote Link to comment https://forums.phpfreaks.com/topic/216720-explode-replacement-or-a-work-around/#findComment-1126329 Share on other sites More sharing options...
roopurt18 Posted October 25, 2010 Share Posted October 25, 2010 If this worked before and it doesn't work now that means your PHP host went backwards in PHP versions, which is unlikely. What exactly did they change? Be very, very specific. Quote Link to comment https://forums.phpfreaks.com/topic/216720-explode-replacement-or-a-work-around/#findComment-1126331 Share on other sites More sharing options...
litebearer Posted October 25, 2010 Share Posted October 25, 2010 if all you are doing is removing the last element, perhaps array_pop Quote Link to comment https://forums.phpfreaks.com/topic/216720-explode-replacement-or-a-work-around/#findComment-1126337 Share on other sites More sharing options...
KingOfHeart Posted October 25, 2010 Author Share Posted October 25, 2010 It's the -1. I removed the -1 and it seems to work just fine. Told you it was the version issue. Forgot to mark solved. Quote Link to comment https://forums.phpfreaks.com/topic/216720-explode-replacement-or-a-work-around/#findComment-1126438 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.