Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p><strong>Edit:</strong> To obtain the decimal value at the beginning of a string, you can use <code>sscanf</code>:</p> <pre><code>$url = '87262-any-thing-here.html'; list($realid) = sscanf($url, '%d'); </code></pre> <p>In case the URL has no decimal number at the beginning, <code>$realid</code> will be <code>NULL</code>. With <code>explode</code> you will get an undefined result depending on URL.</p> <hr> <p><a href="http://php.net/array_shift" rel="nofollow noreferrer"><code>array_shift</code><sup><em>&shy;Docs</em></sup></a> by it's function reference needs a variable:</p> <hr> <p><img src="https://i.stack.imgur.com/MfVG5.png" alt="enter image description here"></p> <hr> <p>(see as well: <a href="http://de.php.net/manual/en/language.references.pass.php" rel="nofollow noreferrer"><em>Passing by Reference</em></a>)</p> <p>But you give it a function:</p> <pre><code> $realid = array_shift(explode("-", $id)); </code></pre> <p>I would not expect it to always properly work because of that. Additionally this can trigger warnings and errors on some installations.</p> <p>Instead use a variable:</p> <pre><code> $ids = explode("-", $id); $realid = array_shift($ids); unset($ids); </code></pre> <p>Or in your case:</p> <pre><code> list($realid) = explode("-", $id); </code></pre> <p>which will assing the first element of the array returned by <code>explode</code> to <code>$realid</code>. See <a href="http://php.net/list" rel="nofollow noreferrer"><code>list</code><sup><em>&shy;Docs</em></sup></a>.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload