Jump to content

nuttycoder

Members
  • Posts

    233
  • Joined

  • Last visited

    Never

About nuttycoder

  • Birthday 04/15/1981

Contact Methods

  • Website URL
    http://www.phphelptutorials.com

Profile Information

  • Gender
    Male
  • Location
    Hull

nuttycoder's Achievements

Member

Member (2/5)

0

Reputation

  1. that's brilliant works great I agree with your points, I didn't think having more then one name as key would work either I got to the point where anything was worth a try. I don't tend to use array beyond doing basic things. here's the output now: Array ( [Richard Whiting] => 65 [Ewan Dowes] => 43,2 [Reece Lyne] => 34 [Kirk Yeaman] => 32,27 [Willie Manu] => 16 [Mark Calderwood] => 13 ) what would your recommend is the best way to print out this data so it's like: Richard Whiting 65 Ewan Dowes 43,2 Reece Lyne 34 Kirk Yeaman 32,27 Willie Manu 16 Mark Calderwood 13 thanks very much
  2. Hi guys, I've been trying to get values from some arrays and group them it's kinda hard to explain let me give you an example I have this output: Richard Whiting - 65 Ewan Dowes - 43 Reece Lyne - 34 Kirk Yeaman - 32 Kirk Yeaman - 27 Willie Manu - 16 Mark Calderwood - 13 Ewan Dowes - 2 there are duplicates in the names I need to remove the duplicate name and keep the number but group them so they end up like this: Richard Whiting - 65 Ewan Dowes - 2,43 Reece Lyne - 34 Kirk Yeaman - 27,32 Willie Manu - 16 Mark Calderwood - 13 this is the code I've used to get this far: inside a loop I add the data to an array: $tsname[] = array($r['Team2TeamSheetPersonName'] => $timeLine->Time); $key is the name and $value is the number foreach ($tsname as $key => $value) { foreach ($value as $key => $value) { echo "<p>$key - $value</p>"; } } I've tried everything I can think of and am stuck not sure how to do this, if anyone can provide any help on this I would be very greatful. thanks in advance.
  3. Thanks Guys I should have consulted the manual to see if there way a better way preg_replace_callback is the obvious choice now it's been pointed out to me Works a treat. I'm not using highlight_string as my code snippets are not limited to just php so I'm using google's prettify syntax highlight plugin. Thanks again guys much appreciated!!
  4. Hi Guys, I'm trying to print some code snippets to the screen that's mixed with normal html what I'm trying to do is use htmlentities to convert the snippets. This would only convert text inside [ code ] [ /code ] tags. Using preg_replace I've managed to isolate the snippets but I cannot use htmlentities without causing an error. As I need to add the snippets back into the string it came from before bring printed. Here's what I've been using replacing all code tags with <pre class="codeprint">snippets here</pre> $pr->postDesc = preg_replace("/\[code\](.+?)\[\/code\]/is","<pre class=\"codeprint\">$1</pre>", $pr->postDesc); An example of what $pr->postDesc contains: <p>testing</p> [ code ] <?php echo $test;?> [ /code ] Hope you can understand what I mean.
  5. you can get the data from a session by using the session name and adding it to a variable like this: $data = $_SESSION['item']; Then you can save that information into a text file $file = "session.txt";//set a name for a text file will be created if it does not exist $fo = fopen($file, 'w');//open the file fwrite($fo, $data);//write data there fclose($fo);//close file
  6. yes you need to select the database to use like this; $conn = mysql_select_db ($database)or trigger_error(mysql_error(),E_USER_ERROR);
  7. one restriction is the time the script take it there's a lot of files or big files it can timeout you can increase the time limit but may be restricted depending on the server setup set_time_limit(200);
  8. thats why there's functions call the functions as many times as needed.
  9. hmm that's odd never got that myself, the else should only run if the folder was created, if you remove the error supressor @ you'll see what the server says when making folder can't remember off hand it's been awhile since I used the script.
  10. it's because your using mysql_fetch_object at the top but using array notation when calling the items such as $row['Name'] when using mysql_fetch_object use the -> notation so $row->name. or change mysql_fetch_object to mysql_fetch_array
  11. thats all the files I made for it, it's a very basic there is no html files/interface as when I made it, it was just to copy files from one server to another so I din't need any sort of visuals for it. The functions are there to make is easier to reuse the code, to say copy a file from one server to another, you use the ftp connect function and supply the ftp login to the remote server you want to copy to then use the copyfile function and pass the folder to where you want to copy the file to then the path to where the file is on the current server. ftpconnect("ftp.server.com","username","password"); copyFile($conn,"path/to/file/filename.ext","filename.ext");
  12. had the wrong quotes <?php while ($row = mysql_fetch_array($queryasia)) { echo('<tr><td>' . '<a href="country.php?code='.$row['Code'].'> ' . $row['Name'] . '</a></td><td>' . $row['Population'] . '</td><td>' . $row['GNP'] . '</td><td>' . $row['GovernmentForm'] . '</td></tr>'); } ?>
  13. The semi-colon is not required when the PHP closing tag appears on the same line. But I would use it anyway. I din't know that learn something new everyday still woulden't do it that way, same as I never use <?=$title;?>
  14. try <input type="text" name="book" value="<?php echo $title; ?>" /> it was missing the ;
  15. oh sorry I misread your first post I thought you said define when you said declare, I've never used declare.
×
×
  • 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.