Jump to content

marmelade7

Members
  • Posts

    11
  • Joined

  • Last visited

marmelade7's Achievements

Member

Member (2/5)

0

Reputation

  1. I was hoping for a specific example that shows a preg_match_all statement that ends up with something like: $totalMatchedItems=5. The examples I see show a bunch of array info, but don't make it clear (at least not to me) how to count these nested arrays.
  2. I've already been through all that stuff. I need someone to explain where the answer is. I've deduced that count($matches[0]) contains the answer, but count($matches[0]) does not always work. The examples show me how to print the results in the array -- I still do not see how to count them.
  3. I've already been through all that stuff. I need someone to explain where the answer is. I've deduced that count($matches[0]) contains the answer, but count($matches[0]) does not always work.
  4. But how DO I count the matches? I've already looked at examples but I still don't get it.
  5. My goal is to reliably count the number of matches in a preg_match_all operation. The following code works fine in a separate PHP page. However, it does NOT work when I include it in other php code. Same code: different result. preg_match_all('/[0-9]{1,}[-]{1}[0-9]{1,}/',$txt,$matches); $c=count($matches[0]); preg_match_all('/[A-Za-z]{1,}[-]{1}[A-Za-z]{1,}/',$txt,$matches); $d=count($matches[0]); echo "c count=".$c; echo "d count="$d; Why does this code NOT work when I include it in other PHP code, even though this code works in a php page by itself? How can I reliably count the number of matches in a preg_match_all operation. I know I use "matches" and I know there are nested arrays. However the statement count($matches[0]) does not always work.
×
×
  • 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.