PHP equivelant of Perl line?

Can someone tell me if I'm right with this? I'm trying to port a fairly massive perl script into OO-PHP, and have been stuck on a few things, this is one of them and just need some confirmation if I'm doing it right, the perl code is:

my ($command,@args)=split(/\n/,$message);

is this the same as doing this in PHP?

list($command, $args[]) = preg_split('/\n/', $message);

Answers


No. What you're trying to do is invalid and will not work. The equivalent PHP code would be:

$args = preg_split('/\n/', $message);
$command = array_shift($args);

The use of preg_ functions should be only used when necessary, so you could actually replace the preg_split with:

explode("\n", $message);

Need Your Help

CakePHP and linker tables

php cakephp

I have the following 3 tables in my CakePHP app:

http post without libraries with C

c api http rest post

I need to make use of an API REST with my program written in C. For that I need to make http requests, specifically the POST method.

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.