• Hello,
    I was wondering how I could create new custom field from field that I already have in the post.
    i.e.
    $link = https://example.com/i/999999/word

    I would like to have second field where I will have only the digits: 9999999
    like $link2 -> 999999 ( the entire number sometimes could be from 8 digits sometimes from 9

    Could someone help me with this ??
    Reply

Viewing 1 replies (of 1 total)
  • I am a little confused about the ‘custom field’ part. If all you want is to extract the 8 or 9 digits into a variable, you can do it like this:

    $link2 = (preg_match('#/(\d{8,9})/#',$link,$matches)) ? $matches[1] : '';

Viewing 1 replies (of 1 total)
  • The topic ‘create new custom field from field’ is closed to new replies.