Jump to content

effigy

Staff Alumni
  • Posts

    3,600
  • Joined

  • Last visited

    Never

Posts posted by effigy

  1. I think democracy and capitalism/free enterprise are decent concepts by themselves, but putting them together seems to be a bad idea, as they seem to corrupt each other.

     

    It's a catch-22.

     

    Agreed on both points.

     

    How are Denmark's politics in comparison?

  2. Daniel:

     

    I see your point; however, how many people:

     

    • bother looking outside of the Democrat/Republican realm
    • are aware that there are more (realistic) choices prior to seeing the ballot
    • do not rely solely on the TV for getting their information

     

    Frankly, many of the people I've encountered know next to nothing about other parties (myself often included!). If the debates were open, the media not Democratic- and Republican-centric, etc., people would actually know something about them, and perhaps just enough to make them think down a different path, thus, opening up possibilities. After all, I thought that's what America is supposed to be about.

     

    Crayon:

     

    Are you an anarchist by chance? What solution do you propose againt these evils?

  3. I usually don't vote, because I do not believe in picking the lesser of the two evils.

     

    What about the rest of the "evils"? There were 7 presidential candidates on my ballot.

     

    Okay let me amend that to "Lesser of the $x evils." 

     

    So you were well-informed on every single candidate running, enough to deem them all "evil"?

  4. <pre>
    <?php
    $cups = array(
    	'FA Cup',
    	'FA Cup Qualifying Round 1',
    	'FA Cup Qualifying Round 2',
    	'FA Cup Qualifying Round 3',
    	'FA Cup Round 1',
    	'FA Cup Round 2',
    	'Carling Cup',
    	'Carling Cup Round 1',
    	'Carling Cup Round 2',
    );
    $seen = array();
    foreach ($cups as $cup) {
    	$cup = preg_replace('/(?<=\bCup)\b.+$/', '', $cup);
    	if (array_key_exists($cup, $seen)) {
    		continue;
    	}
    	$seen[$cup] = null;
    	echo $cup, "\n";
    }
    ?>
    </pre>
    

  5. Some tips:

     

    [*]Change your delimiters to avoid multiple escapes

    [*]When using literal data inside of a pattern, always escape it using preg_quote

    [*]Use character classes in place of one character alternations, e.g., (a|b|c)

     

    I suspect the second bullet may alleviate your problem.

  6. How about something like this?

     

    <pre>
    <?php
    $data = <<<DATA
    \$my_array = array(
        'key' => "value",
        'another_key' => 'another_value'
    );
    DATA;
    
    preg_match_all('/^\s*(\$\S+\s*=\s*array\(.*?\);)/ms', $data, $matches);
    array_shift($matches);
    print_r($matches);
    foreach ($matches[0] as &$match) {
    	preg_match('/^\s*\$(\S+)/', $match, $name);
    	eval('$array = ' . $match);
    	$result[$name[1]] = $array;
    }
    
    print_r($result);
    ?>
    </pre>
    

  7. <?php
    $data = <<<DATA
    I dont understand a little about RegEx but cannot really understand how to use all the funtions . I need to convert link tag <a href ....> that DOES NOT already have the css in them. Such as <a href="http://www.google.com" style="font-size: 11px;" other properties> should NOT matched but <a href="http://www.google.com" .. other properties> should match and a style="..." should be added.
    DATA;
    
    echo htmlspecialchars(preg_replace('/<a((??!style=)[^>])+)>/', '<a style="xyz" $1>', $data));
    ?>
    
    

  8. Shorthands are not available in EREG; use PREG. Also, why the \s?

     

    <pre>
    <?php
    function valid_propadd($pa) {
    	return preg_match('/(?:\w\s?)+/', $pa);
    }
    
    $tests = array(
    	'120_Ho_St',
    	'120_Howe_St',
    );
    
    foreach ($tests as $test) {
    	echo $test, ' => ', valid_propadd($test) ? 'Valid' : 'Invalid' ;
    	echo '<br>';
    }
    ?>
    </pre>
    

  9. For it to work now the first letter of the actual name must be upper case. Otherwise it doesn't find the name, is there a way that I can make it so that even if the first letter they put in isn't capital, it will still find the name?

     

    ucfirst(strtolower("Name"));

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