Re: Passing an array to a C program from a php script??

From: Date: Wed, 27 Jun 2001 06:01:47 +0000
Subject: Re: Passing an array to a C program from a php script??
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-55326@lists.php.net to get a copy of this message
> I have a big array (nearly 1000 lines) that I would like to pass to a C > program. I don't want to create a temporary file to pass my array (If > possible ?!?), and I don't think the command line will fit my needs. > > Is there a way to execute a program with a php string as the standard > input. Something like shell redirection 'c_program < input.file' but with > input.file being a php variable and not a real file ?? Any other solution > ?? 2 choices: #1 (for the real hacker geek) Compile your C program *into* PHP as a function, using the PEAR stuff. You may need to use PHP's http://php.net/serialize function to turn your array into a giant string and write a C routine to unserialize it, or, by the time you get done converting your program to PEAR, it will just accept your PHP array as an argument. #2 (pretty slick, though...) Run your C program using http://php.net/psockopen and use http://php.net/fputs to spew your data at it one line at a time. -- WARNING richard@zend.com address is an endangered species -- Use ceo@l-i-e.com Wanna help me out? Like Music? Buy a CD: http://l-i-e.com/artists.htm Volunteer a little time: http://chatmusic.com/volunteer.htm

« previous php.general (#55326) next »