Ready to get started?Download WordPress


[resolved] get only text between a <b> sign with "preg_match" ?! (4 posts)

  1. Begin
    Posted 5 years ago #

    I don't really understnd how to work with this preg_match,
    but I think it can do what I need easily...

    I need him to echo back only the text that is inside for example
    two <b> signs or <sdfg> signs or what ever sign I will give him...

    Does anyone know's how to do that?

  2. s_ha_dum
    Posted 5 years ago #

    $test = '<html><head></head><body><p>hi</p><p><b >hello</b><b>Goodbye</b></p></body></html>';

    This is very basic and not very robust. A tag like < b> will throw it off though <b > won't. Basically the syntax comes from here.

  3. Begin
    Posted 5 years ago #

    Great! thank's.

    But i can't get it completly working as I want:

    I wrote:

    $preprice = "text text text <price>34</price> more text text text";
    preg_match_all("#<price\b[^>]*>(.*?)</price>#", $preprice, $matches);
    $price = "$matches";
    add_post_meta($post_ID, 'price', $price);

    and it add a post meta with a value "array" and not "34"
    as I want...


  4. Begin
    Posted 5 years ago #

    I got it right, thank's!!! it's just great!!!

Topic Closed

This topic has been closed to new replies.

About this Topic