GoFuckYourself.com - Adult Webmaster Forum

GoFuckYourself.com - Adult Webmaster Forum (https://gfy.com/index.php)
-   Fucking Around & Business Discussion (https://gfy.com/forumdisplay.php?f=26)
-   -   Any php gurus here? Array_walk help needed (https://gfy.com/showthread.php?t=428022)

smashface 02-06-2005 06:57 PM

Any php gurus here? Array_walk help needed
 
Im trying to create a file by using each element of an array as the filename. I have the following code and am getting an Invalid argument error.

$newfile = file("newdata.txt");

function touchfile($foo) {

touch($foo);

}

array_map ("touchfile", $newfile);

The error is occurring in the touch line.

Any suggestions are appreciated.

Chris

swedguy 02-06-2005 07:01 PM

HAve you checled what newdata.txt contains?

swedguy 02-06-2005 07:02 PM

edit....

Spudstr 02-06-2005 07:04 PM

sure your permissions are alright?

smashface 02-06-2005 07:11 PM

Quote:

Originally Posted by swedguy
HAve you checled what newdata.txt contains?

it contains the text I want

ex. foo.html
foo1.html

smashface 02-06-2005 07:13 PM

Quote:

Originally Posted by Spudstr
sure your permissions are alright?

Im testing on a Windows machine using Abyss Webserver plus PHP5. I'm able to get a literal value to be the filename. If I change;

touch($foo);

to

touch('$foo');

it will create the file $foo

swedguy 02-06-2005 07:15 PM

This works:

Code:

<?php

$newfile = file("test.txt");

function touchfile($foo) {
        $foo = trim($foo);
        touch($foo);
}
array_walk($newfile, 'touchfile');
?>


woj 02-06-2005 07:17 PM

what's the error you are getting?

smashface 02-06-2005 07:21 PM

Thanks swedguy. I guess there was a space/carriage return that was causing an error.

swedguy 02-06-2005 07:21 PM

Hmm, just adding double quotes on the trim() in the original code works too. Odd.


All times are GMT -7. The time now is 10:11 PM.

Powered by vBulletin® Version 3.8.8
Copyright ©2000 - 2025, vBulletin Solutions, Inc.
©2000-, AI Media Network Inc123