Jump to content

JAY6390

Members
  • Posts

    825
  • Joined

  • Last visited

Everything posted by JAY6390

  1. preg_match('~<th>Proxy:</th><td>(.*?)</td>~i', $subject, $matches); echo $matches[1];
  2. You could also just remove the class from the images with one regex, then add it to all images with another This will remove all classes from the img tags $result = preg_replace('/(<img\b[^>]*) class=\'[^\']+\'([^>]*>)/m', '$1$2', $subject); Then you just replace all images with a class. You will probably need to extend the above a little to have the tags around the img tags too, but that works for removing all image classes
  3. This would be so much simpler if you just did it with jQuery to add the class, or better still just give the <ul> an id and then use $('#ul_id_here > li > a > img') to select all of the images in the ul. You can then remove all classes from them, and replace with the ones you want, or just use the selected images directly with that
  4. Can't really do it like that as far as I'm aware. one solution is the following /^([\w\.-]*'?[\w\.-]*)$/ Note that \w matches a-zA-Z0-9 and \_
  5. JAY6390

    Reg Ex Help

    it's likely to be an issue with an extra line. Just put array_pop($content); just before this line $count = count($content); which should do it
  6. JAY6390

    Reg Ex Help

    Change ([\d\.]+)~ to (-?[\d\.]+)~
  7. JAY6390

    Reg Ex Help

    ah, you need a \ after the word "price" in the regex before the [ and it should work
  8. JAY6390

    Reg Ex Help

    After echo $content[$i]; use preg_match("~price['([^:]+):CUR'] = ([\d\.]+)~", $content[$i], $matches); $country_code[$i] = $matches[1]; $rate[$i] = $matches[2];
  9. JAY6390

    Reg Ex Help

    If you show how you've got it to that stage, I'll put in an example
  10. JAY6390

    Reg Ex Help

    ~price['([^:]+):CUR'] = ([\d\.]+)~ Match 1 would be the AFN, match 2 would be the amount
  11. Upon second inspection, no they did not Clearly today has been too long already lol
  12. I did actually mean to put in the ^ anchor, oops. True the | doesn't need a \ before it, but only if the ^ is before it. if left without the ^ anchor and no \ before the |, it won't be a valid regex. I generally escape all special characters just out of habit to be honest, even when not needed inside character classes etc
  13. $result = preg_replace('/\|\s*file\s*=/im', '', $e);
  14. The regex is the FIRST parameter, the subject is the second. You have them the wrong way around
  15. $pattern = '~<font class="class_1">([^<]+)</font>~';
  16. Autofresh is: <?php $link = isset($_GET['on']) ? 'hits.php?on' : 'hits.php?off'; echo isset($_GET['on']) ? 'Enabled |<a href="?off"> Disable?</a>' : 'Disabled |<a href="?on"> Enable?</a>'; ?>
  17. Is the field set to auto_increment?
  18. Not possible to get a mac address. You'll need to use cookies and/or a session variable
  19. http://www.w3schools.com/PHP/php_mysql_select.asp
  20. $r = array ( 0 => array ( 'Car' => array ( 'id' => '2', 'name' => 'BMW', ), 'Owner' => array ( 'id' => '4', 'car_id' => '2', 'name' => 'Bob', ), ), 1 => array ( 'Car' => array ( 'id' => '4', 'name' => 'Mercedes', ), 'Owner' => array ( 'id' => '4', 'car_id' => '4', 'name' => 'Jules', ), ), 2 => array ( 'Car' => array ( 'id' => '4', 'name' => 'Mercedes', ), 'Owner' => array ( 'id' => '4', 'car_id' => '4', 'name' => 'Simbad', ), ), 3 => array ( 'Car' => array ( 'id' => '4', 'name' => 'Mercedes', ), 'Owner' => array ( 'id' => '4', 'car_id' => '4', 'name' => 'El Savador', ), ), ); $cars = array(); foreach($r as $v) { if(isset($cars[$v['Car']['id']])) { $cars[$v['Car']['id']]['Owners'][] = $v['Owner']; }else{ $cars[$v['Car']['id']] = array('Car' => $v['Car'], 'Owners' => array($v['Owner'])); } } echo '<pre>'.print_r($cars, true).'</pre>'; Is that more what you had in mind?
  21. can you use var_export($owners); and paste the code it generates
×
×
  • 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.