Jump to content

cpd

Members
  • Posts

    883
  • Joined

  • Last visited

  • Days Won

    5

Posts posted by cpd

  1. Validation isn't specific to php, it should be applied whenever user input is accepted. You're essentially verifying the user has entered valid content as opposed to content that could harm your service.

     

    Search "defensive code" or "data validation" in google, you'll get a load of stuff.

  2. Your better off using Python as it has a variety of useful libraries such as nupmpy and scikit. You'll want to apply a kernel to the image such as a 3x3 kernel with -1 along the top row and 1 along the bottom. This will highlight horizontal edges and rotating the kernel 90 degrees will yield vertical edges. Combining the two will yield edge detection. The topic gets increasingly complex and to be totally honest, is probably unnecessary for your purpose. 

     

    If you're always scanning cards of the same size, why not predefine the area and cut that area out? 

  3. Everyone should hate it, its just a really big class - pile of (insert very foul word).

     

    I'm extremely fond of laravel. Put together such that its relatively intuitive and provides some extremely useful features. Its also quite a mature framework which is generally a good thing.

  4. I think you're asking if there's a cleaner solution as opposed to can you use implode.

     

    Personally, I'd store just the URLs and loop with a foreach statement to print them.

     

    $dirs = array_diff(scandir($dirlocation), array('..', '.'));
    array_walk($dirs, function(&$v, $k, $d) {
       $v = $d . $v;
    }, $dirlocation); 
    
    // HTML section
    <?php foreach($dirs as $url) : ?>
    // IMG tag with SRC = $url
    <?php endforeach; ?>
    
  5. To only show mp3 files you can run an $dot = strrpos($file, ".") on the file name to get the last occurrence of a dot then substr($file, $dot+1, strlen($file)) and test if its equal to mp3. Alternatively, you could explode using the dot and get the last item in the array, and test if that's equal to mp3. The rest is self explanatory.

     

    With regards to keeping the directory structure: you need to know if an mp3 file is in a directory before you can display it. You could do this by scanning everything and creating an array of the directories and any MP3's they have in them. Then remove any directories that reference an empty array.

     

    i.e.

     

    array(
       'dir1' => array(
          'something.mp3'
       ),
       'dir2' => array()
    ...
    

     

    After you've built your array representing a directory structure as above, cycle through it and remove anything referencing an empty array such as 'dir2'. Without scanning the directory once, its impossible to know if it contains an MP3. 

     

    To stop linking the directories, just remove the hyperlink after testing if its a directory or not. (http://php.net/is_dir).

     

    Just a couple of ideas off the top of my head.

  6. No you don't need to use the StdClass. A variable has a name: $username = "cpd";. Why is this not satisfactory? Given your description for the problem, there's no need to use an object at all.

     

    @web_craftsman: from what you've suggested you don't seem to know what an object is for, when to use it, or how to use it. 

  7. Use a variable. Why are you using an object? There is absolutely no need for an object here and this is not object oriented programming in the slightest. You're just creating objects and giving them properties they shouldn't have and then assigning something to the property; that entire process is basically the same as assigning a normal variable.

  8. A select menu isn't a colour and shouldn't be a property of a "Color" object. A "Select" could be an object of its own. 

     

    @web_craftsman: You shouldn't really declare properties on the fly as you then open a can of encapsulation issue worms. 

×
×
  • 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.