Jump to content

Michdd

Members
  • Posts

    510
  • Joined

  • Last visited

    Never

Everything posted by Michdd

  1. That's not the reason this isn't plausible in my situation.
  2. Is there really no other way? This isn't really an option in my case..
  3. I have a field which contains a name, the name may contain 2-3 names (first, middle, last).. I want to order the query by the last name alphabetically. Is there a way I can use like end(explode(' ', name)) inside the query. So it'll order by the last name?
  4. What's the easiest way to get the key of a multidimensional array. Like this: $arr = Array( 'number1' => Array('foobar', 'foobar2') ); What would be the easiest way to get 'number1' from either foobar or foobar2? Is it possible to get without running a full loop?
  5. Web server. First I was testing it on my local web server, which is much slower than my paid hosting. So yea, same as what I said before, when it runs on a faster server it's like constant information 'pouring' in. But locally (slower) it's like stop and go.
  6. Actually.. I think it's something else.. What I'm doing takes a long time to complete (more than 10 minutes depending on the scale of the current operation). It seems to actually be doing it on both ways. Within the loop the opperation that I'm doing takes between 0.06 and 0.5 seconds. Depending on the method of which I'm doing it, I'm still working out the most efficient way. It seems that when it's working at about 0.06 seconds/loop it displays line and line and kind of looks like a live thing. But when it takes long, like .5seconds /loop it goes and stops. It won't display anything for a few minutes, then it'll display the results from the first couple hundred loops, and a few minutes later it'll display the next couple hundred.
  7. How can I optimize this? There might be some white space between the <span> opening and closing tags and the <a> tag(s). preg_match_all('/\<span class="cclass"\>(.+?)\<\/span\>/s', file_get_contents('http://twitter.com/' . $user), $matches); for($i = 0;$i < count($matches[1]);$i++) { preg_match('/\<a href="(.+?)"/', trim($matches[1][$i]), $found[$i]); $results[] = substr($found[$i][1], 1); } return $results;
  8. I noticed that if I'm running something that uses a lot of resources and won't completely finish (Like a really long loop) in a short period of time it will output to the browser, but continue to run and update as it outputs. (Because there's an echo in the loop) But I also noticed I don't get the same effect when this inside of a function. while(something) { echo 'foobar'; } as opposed to: function runWhile() { while(something) { echo 'foobar'; } } The first will output as it goes along, as opposed to the second which won't load the page the same way. Why is this, and is there any way to make the second behave the same as the first?
  9. Oic. That's much better logic than what I'm currently using. Thanks.
  10. I guess this question is somewhat about spidering.. I'm writing something that will grab certain things from a web page, it then uses that info to request another web page and get information from that. Repeating this process. I have a function with grabs the necessary stuff so I just do something like this: foreach($something as $part) { $sub = getInfo($part); ... foreach($sub as $subsub) { ... } ... } And I could keep repeating those loops inside each other to go down more and more. But is there a way to do that without actually writing the loops? Say I wanted to go down 10 levels, I don't want to write 10 loops.
  11. I'm always looking for ways to do things better, improve and learn. Before getting into creating a template class I never really looked at any tutorials or anything. I just created my own based upon the principles of it. I'm just curious as to how some of you accomplish this. The way I generally do it is something like this: $templateObjects = Array( 'some_file' => Array( '{EXAMPLE_1}', '{EXAMPLE_2}' ) ); class Template { var $template; function __construct($title) { $this->template = str_replace('{PAGE_TITLE}', $title, file_get_contents('template/html/main.html')); } public function setContent($section, $content) { $this->template = str_replace($section, $content, $this->template); return true; } public function display() { echo $this->template; return true; } } function getContent($template, $content) { global $templateObjects; $structure = @file_get_contents('html/' . $template . '.html'); if(!$structure) return 'Error: Template file not found (' . $template. '.html)'; return str_replace($templateObjects[$template], $content, $structure); } The way it would work is I'd have a main template file (main.html), that would contain the skeleton of a page, outlined so breifly enough so it can be used for all pages. Say within this skeleton I had something called {MAIN_CONTENT}, and I wanted to replace that with the contents of some_file.html while replacing {EXAMPLE_1} and {EXAMPLE_2} with "Hello" and "World" I would do something like this: //Create class instance $template->setContent('{MAIN_CONTENT}', getContent('some_file', Array('Hello', 'World'))); $template->display(); How do you do it? Is mine appropriate and is there anything I could do better?
  12. I'm creating a map editor for a tile-based game in JavaScript/PHP. I'm planning on having 2 sections, one of the left (which will contain the map GUI) and the right will contain the list of tiles to select from. The problem is that I want to set overflow for the map div but because I have to use margins for the tiles to set properly the overflow never triggers. Even I have overflow: auto; if the map is large it'll still display outside of it's element's box.
  13. Is there a way to make an element (More specific images) unaffected by others? Like say I put <img src="something.png" alt="" /><img src="something.png" alt="" />, is there a way to make it so they would overlap completely?
  14. I know I can get the coords through document.images.imagename.offsetTop and offsetLeft. But as far as I know it's not possible to edit the image's coordinates though that. Is there another way? Because I need to be able to create new images, and set their x,y
  15. Is it possible to grab, and set the x,y coordinates of images? I'm wondering because I want to create a map editor for a tile-based game in JS/PHP. It's just for fun, I can already do this in flash without a problem. I'm just curious if it's possible this way.
  16. Solved. Solution: file_get_contents(dirname(dirname(__FILE__)) . '/template/html/main.html')
  17. That doesn't solve my problem. I get the same results using that. I think I can probably use something like in my template class to include the template files. But I must be doing it wrong. It looks like this: file_get_contents('template/html/main.html') I think I have to use __FILE__ to access the path(root/template/html/main.html) from this file(root/class/template.class.php)
  18. This might be kind of a stupid question.. How can I make a path so it'll work even when including the file from another directory? I have a template class that gets it's files like template/html/(FILENAME).html . I have a structure like this: root/common.php <- Includes all nessary files, including class/template.class.php root/class/template.class.php root/anyfile.php <-- This includes common.php, and can use the template class, no problems root/network/network.php <- has (require_once '../common.php' I get an error here because the path used in the class/template.class.php is incorrect in relation to this file.. So basically I need to make the path work so it'll change to be relevant to the file from which it's being included..
  19. Do this: $query10 = mysql_query("SELECT COUNT(id) from articles where art_cat = $cat"); $row10 = mysql_fetch_assoc($query10); echo "There are {$row['COUNT(id)']} articles"; Change COUNT(id) to another row in that table if you don't have 'id'
  20. Technically the owner can still write their own script using cURL to send false information though, right?
  21. I'm creating a system that will be given out to other people, one feature of this will be able to periodically send information to a website about their board, this would put them on a list of active boards with their stats. The way I plan to send the information is through HTTP requests, like ?boardid=325&stats=etc..&whatever=whatever. Although that would be insecure, because to gain false stats anyone could just visit that URL and put whatever they wanted. I thought about encrypted the information then sending it over and decrypting it on my end, but I doubt that would be very successful either because then they'd have the encryptor, and could just hijack my function(s) to encrypt false info as well. Anyone have any ideas?
  22. I have a file of disallowed words, and disallowed regular expressions. Each one on a new line, so I know I can get that into an array just doing like explode("\n", $filecontents); But my question is how would I loop through all those to make sure they're not in the content I want to search? Strpos doesn't take arrays, and wouldn't looping through upwards of over a thousand different things be slow? Additionally, how could I check to see if it's a regular expression? And if it is, use preg_match instead? Say I have this: resourcez.com ecspace.us photoangels /a[^a-z0-9]*n[^a-z0-9]*o[^a-z0-9]*n[^a-z0-9]*t[^a-z0-9]*a[^a-z0-9]*l[^a-z0-9]*k[^a-z0-9]*/i And I want to make sure a string doesn't contain either of the first 3, nor the regex expression. Of course, the actual list is way longer.
×
×
  • 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.