Jump to content

Superian

Members
  • Posts

    66
  • Joined

  • Last visited

    Never

Everything posted by Superian

  1. Thanks wildteen88! With your code, I do no have to use the function!
  2. After each period 01. Plies - Chef (3:28) 02. Plies Feat. Mario & Hurricane Chris - Headboard (3:33) 03. Plies - On Yac (0:49)
  3. This should be simple, but I am having a hard time figuring this thing out! I have a textarea that I am trying to insert multiple values into. <form action="music.php" method="post" > <textarea name="tracks" rows="15" cols="20" id="" tabindex="3" class="" style="width: 300px;"></textarea> <input type="submit" name="submit_tracks" value="Music"> </form> I am having problems placing the results into an array. What am I doing wrong? <?php if($_POST['submit_tracks']) { //This is the array containing the track information $tracklisting = $_POST['tracks']; $tracklisting = array(); //This is the function which will grab anything after the . and return it function trackname($string){ $file = $string; $i = strrpos($file,'.'); $trackname = substr($file,$i+1); return $trackname; } foreach($tracklisting as $track) { $trackoutput = trackname($track); print "<li>".$trackoutput."</li>"; } } else print "No Output!"; ?>
  4. I am trying to write a script that will search for the period(.) in the string below and print everything that follows the period to the screen inside a "list tags". There will multiple tracks that will be needed to print to the screen. <?php $str = " 01. Plies - Chef (3:28) 02. Lil Wayne - U-Stream Freestyle (1:51) "; if(preg_match("/./i", $str)){ for ($i = 0; $i < count($str); $i++) { print "<li>".$str[$i]."</li>"; } } else { print " No Match"; } ?>
  5. Where are you attending class for the flash video player?
  6. http://publicsize.com How much do you think the site should be sold for? I would just sale the site for my price and be done with it.
  7. How could I make this into one function instead of having to use two? <?php function check_plain($text) { return _validate_utf8($text) ? htmlspecialchars($text, ENT_QUOTES) : ''; } function _validate_utf8($text) { if (strlen($text) == 0) { return TRUE; } return (preg_match('/^./us', $text) == 1); } ?>
  8. I am trying to write a script that checks whether a string is valid UTF-8, but I have no idea where to start. Any ideas? Thanks!
  9. It doesn't display any output still! Any help please!
  10. I'm sorry, but I am lost buddy. Getting an error! <?php function unset_register_globals() { if (ini_get('register_globals')) { foreach ($GLOBALS as $key => $value) { if (!in_array($key, array('_ENV' => 1, '_GET' => 1, '_POST' => 1, '_COOKIE' => 1, '_FILES' => 1, '_SERVER' => 1, '_REQUEST' => 1, 'GLOBALS' => 1))) { unset($GLOBALS[$key]); } else ($GLOBALS[$key] == false) { print "Unset"; } } } } unset_register_globals(); ?>
  11. Could someone please give me an idea about how to check the following script to see if its working properly? Thanks! <?php function unset_register_globals() { if (ini_get('register_globals')) { foreach ($GLOBALS as $key => $value) { if (!in_array($key, array('_ENV' => 1, '_GET' => 1, '_POST' => 1, '_COOKIE' => 1, '_FILES' => 1, '_SERVER' => 1, '_REQUEST' => 1, 'GLOBALS' => 1))) { unset($GLOBALS[$key]); } } } } ?>
  12. (such functions are glob or mysql_fetch_object) I understand the mysql_fetch_object, but what do you mean by glob with in a function?
  13. There isn't a method nor is there a class!
  14. There is no class, so how is OOP being used? I was thinking that there is way to use the arrow with out having to define a class, but I don't know how. Thanks!
  15. I have no idea how to use the arrow syntax, so could someone please write a simple example that outputs a string using the arrow syntax? The arrow syntax should work without using OOP, correct? Thanks! $files->filename
  16. Trium918 this isn't working. Could someone please help me out? Thanks!
  17. This is what I was trying to do, but it isn't working the way that I want it to! Read the comment in the script below! <?php // A string describing a level to load. Each level adds to the // previous one, so invoking a later level automatically runs the earlier // level too. function load($level) { $levels = array('level 1', 'level 2', 'level 3'); foreach ($levels as $i => $level) { $current_level = $level; unset($levels[$i]); _load($current_level); } } function _load($level) { switch($level) { case 'level 1': print "Test Line 1"; break; case 'level 2': print "Test Line 2"; break; case 'level 3': print "Test Line 3"; break; } } // levels 2 and 3 shouldn't run because I only used level 1 as a param, // but if I used level 3 as the param then all should run! // Get my point? If I call level 3, then all level adds to // previous one, so invoking a later level automatically runs the earlier // level too. If I call level 2, then only level 2 and level one runs and not // level 3 load('level 1'); ?>
  18. I'm not saying it's a bad idea to use a static variable when there is a reason to, even in a simple script. I just can't figure out what the reason for one here is. Again, not saying it's wrong, but I just don't see the need for one... I am using it to run the script below, so is there a better way of writing the script with out using the variable scope? <?php $level = 10; static $levels = array('level 1','level 2','level 3'), $level_index = 0; while ($level >= $level_index && isset($levels[$level_index])) { $current_level = levels[$level_index]; unset($levels[$level_index++]); } <?
  19. It works! Thanks Trium918, but Obsidian has a point! Obsidian why is it a bad idea to to use static to parse my simple script!
  20. I would like to declare $level_index after the array. Is there a way that this could be done? Thanks for the reply!
  21. Someone please explain the error that is occurring with in the script below. <?php // Parse error: syntax error, unexpected ',' $level = array('leve 1','level 2','level 3'), $level_index = 0; $i = 0; while ($i < 5) { print $level[$i].'<br>'; $i++; } ?>
  22. I've read the article on php.net but I am still not getting it. Could someone please explain to me in depth about how to use variable scope correctly?
  23. I understand. What about the code below? <?php if (ini_get('register_globals')) { foreach ($GLOBALS as $key => $value) { if (!in_array($key, $allowed = array('_ENV' => 1, '_GET' => 1, '_POST' => 1, '_COOKIE' => 1, '_FILES' => 1, '_SERVER' => 1, '_REQUEST' => 1, 'GLOBALS' => 1))) { unset($GLOBALS[$key]); } } } ?>
×
×
  • 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.