N.Schipper
N.Schipper

Reputation: 1668

Preg_match somehow not finding part of string

I am having a problem with preg_match in that it is not returning anything. While according to: http://gskinner.com/RegExr/?=35ls9

It should be functioning properly.

This is my current code:

$string == <a class="twitter-timeline" href="https://twitter.com/...." data-widget-id="352777062139922223">....</a>...

its simply the embed code twitter throws out when creating a widget. Was also included in the example.

$string = get_field('twitter_feed');  //contains the string.
preg_match('/data-widget-id="([0-9]*)"/', $string, $match);
var_dump($match);

Its probably something really simple that i am missing. Hopefully somebody is able to help me with this problem.

edit: added the sample string.

Upvotes: 0

Views: 106

Answers (1)

Expedito
Expedito

Reputation: 7795

Test it with the following string. I did, and it works fine:

$string = 'data-widget-id="352777062139922223"';

Make sure that get_field is returning a string in that form.

Upvotes: 1

Related Questions