Jump to content

kev@num

Members
  • Posts

    21
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

kev@num's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. Hi thanks for your reply, sorry I probably didn't explain correctly, the data is unfortunately already grouped when I receive it so I can't change this I need to split the values @ AAAAAA, BBBBBB, CCCCCC etc so that I can manipulate this data separately. - It just shouldn't be grouped in the first place, hence my problem! any more help would be greatly appreciated
  2. I'm getting very confused trying to imagine nested arrays in my head!
  3. Hi, I'm not sure if this is a wierd one, I have lots of arrays i'm looping through like this to see them:- for($i=0; $i <count($confirmed); $i++){//loop through print_r_html($confirmed[$i]); } Which shows the following :- Array ( [0] => AAAAAA-BBBBBB [1] => 2 [2] => 2010-09-29 ) Array ( [0] => AAAAAA-BBBBBB [1] => 2 [2] => 2010-09-28 ) Array ( [0] => CCCCCC-DDDDDD-EEEEEE [1] => 3 [2] => 2010-09-29 ) Key 0 is a Groupconcat split by "-" Key 1 shows how many fields are in 0 Key 2 is just the date What I would like to do is split the first array into 2 arrays, the second in 2, and the third into 3 (therefore ungrouping the groupconcat if you will) as such:- First into these two:- Array ( [0] => AAAAAA [1] => 2 [2] => 2010-09-29 ) Array ( [0] => BBBBBB [1] => 2 [2] => 2010-09-29 ) Second into these two:- Array ( [0] => AAAAAA [1] => 2 [2] => 2010-09-28 ) Array ( [0] => BBBBBB [1] => 2 [2] => 2010-09-28 ) Third into these two:- Array ( [0] => CCCCCC [1] => 3 [2] => 2010-09-29 ) Array ( [0] => DDDDDD [1] => 3 [2] => 2010-09-29 ) Array ( [0] => EEEEEE [1] => 3 [2] => 2010-09-29 ) ) I know I can get out the info from the first of the keys in each array by putting this into the loop:- for($i=0; $i <count($confirmed); $i++){//loop through if($i==0){ $seperated[] = explode("-",$confirmed[$i]);//split by "-" } } print_r_html($seperated); but i'm not sure how to copy the other keys at the same time? If anyone has got any ideas that would be great! thanks in advance Kev.
  4. sweet, thanks for your help, i have now made my variable global and the second echo now comes out ok!!! Thanks again for your time
  5. oO I tried echoing the variables again, but the second one seems to be coming out as: ftp://:@ with all the details missing. for some reason, it's not remembering them further down my code!? (ps allow_url_fopen is turned on)
  6. Hi rwwd, thanks for your advice, i have tried to echo the two but they come out exactly the same. I will try allow_url_fopen and see if that works it's wierd because $one = "ftp://me:password@ftp.mydomain.com/public_html/edit/editme.txt"; works but $two = "ftp://".$username.":".$password."@".$ftpaddy.$editingdir.$editfile; doesn't!
  7. I'm having trouble connecting through fopen using variables as the login details, but with file_get_content it works fine?! These are my variables:- $ftpaddy="ftp.mydomain.com"; $username="me"; $password="password"; $editingdir="/public_html/edit/"; $editfile="editme.txt"; $myftppath = "ftp://" . $username . ":" . $password . "@" . $ftpaddy . $editingdir . $editfile; //puts all variables into string When I try to connect and read the file using the following method it works fine:- $file = file_get_contents("$myftppath", "r"); but when i try and use the same string with fopen as below it doesn't work?! the line i have commented out however works and when i echo the $myftppath variable below it looks the same.. i don't really get it! //$myftppath = "ftp://me:password@ftp.mydomain.com/public_html/edit/editme.txt"; $myftppath = "ftp://" . $username . ":" . $password . "@" . $ftpaddy . $editingdir . $editfile; //puts all variables into string $stream_options = array('ftp' => array('overwrite' => true)); $stream_context = stream_context_create($stream_options); if ($fh = fopen($myftppath, 'w', 0, $stream_context)){//fopen only likes the commented out $myftppath not the one using the variables?! fputs($fh, $newcontents); fclose($fh); } else { die('Could not open file.'); } does anyone know if I am doing the syntax wrong and how to correct it? I read I may need to put another slash after domain.com but this didn't help either. any help would be much appreciated! thanks in advance Kev.
  8. oO i think i just spotted a typo: preg_match_all ('/<!--START-->(.*)<!--END-->/msU', $file, $matches, PREG_SET_ORDER);
  9. Hi, I have the following code which FTPs to a site, gets the source code for a HTML file and then puts the data inbetween <TITLE> and </TITLE> into an array and this works fine: <?php $file = file_get_contents("ftp://user:pass@domain/public_html/index.html", "r"); if (!$file) { echo "<p>Unable to open remote file.\n"; exit; } preg_match_all ('/<TITLE>(.*)<\/TITLE>/msU', $file, $matches, PREG_SET_ORDER); print_r ($matches); ?> Rather than finding a match for data between <TITLE> and </TITLE> however I would like it to pull back what is inbetween the following: <!--START--> and <!--END--> I have tried the following but it doesn't put anything into the array: preg_match_all ('/<!--START-->(.*)<\/!--END-->/msU', $file, $matches, PREG_SET_ORDER); This is the content of the html file if this helps: <TITLE>The Title</TITLE> <!--START--><p><strong>Some Text</strong></p> <p><strong><img src="images/IMAG0152_2.jpg" alt="" width="200" height="100" /></strong></p> <!--END--> i can get a match on stuff between TITLEs but not START and END.. I'm not sure how to change preg_match_all to work!! i've tried loads of combinations but can't get any to work, but i'm not really sure on modifiers and patterns or escaping etc, if anyone could help that would be great. Thanks in advance kev.
  10. echo '<img src="'.$row['image_id'].'">'; not sure if this is what you are after. or to put in place :- .'<img src="'. $row['image_id'] .'">'
  11. Hi, i've had a google, and search but can't find an answer. What I want to do is copy all files from within a folder structure to one directory and not copy the folders - so all files deep within folders appear in one destination folder - no filenames will be the same, so no need to worry about overwriting - no folders are needed in the dest, just the files. I have found the following function for copying files and folders recursively but wondered if I could just comment out a little to get it to do what I want? or if there's an easier way? Thanks in advance, any help would be much appreciated! <?php function COPY_RECURSIVE_DIRS($dirsource, $dirdest){ if(is_dir($dirsource))$dir_handle=opendir($dirsource); mkdir($dirdest."/".$dirsource, 0750); while($file=readdir($dir_handle)){ if($file!="." && $file!=".."){ if(!is_dir($dirsource."/".$file)) copy ($dirsource."/".$file, $dirdest."/".$dirsource."/".$file); else COPY_RECURSIVE_DIRS($dirsource."/".$file, $dirdest); } } closedir($dir_handle); return true; } ?>
  12. hi, i've got a list called $words which I am looping through should ECHO one of these to the browser and for each one of these I want to show a list of filenames which should be made from the second - inner loop. what happens is: the first echo shows and then the inner loop runs but only runs once.. it doesn't run the inner loop for the second echo <?php while (list(, $value) = each($words)) { echo $value ."<br>"; while(false != ($file = readdir($dir))){ if(($file != ".") and ($file != "..")){ echo "<font color='red'>".$file ."</font><br>"; } } } ?> any help would be much appreciated.. do i need to reset the inner loop after each run somehow?
  13. I've had a look, and think I need to use levenshtein() in PHP but not sure how to implement it
  14. Hi, I'm using the following code to read filenames stored in my MYSQL DB and PHP to see if each file exists in a particular folder : <?php do { //loop through filenames in DB if (file_exists($directory.$row_Recordset1['filename'])) { } else { echo $row_Recordset1['filename']; //show the file that doesn't exist } } while ($row_Recordset1 = mysql_fetch_assoc($Recordset1)); ?> This is great in showing me which files haven't been uploaded or the filename is wrong in which case i'll rename it manually. So my question is: Is there a way for it to show me the filename that matches best in that particular directory? Maybe using something like similar_text() or levenshtein() ? -if this is possible i could then make a button to rename the wrongly named file on approval! the script above is my first php script looking/using files/directories etc, i've searched the net but can't find anything like this (yet) any help would be much appreciated. thanks in advance kev. [MySQL 5.0.32 | PHP Version 5.2.0]
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.