Lasha Pareshishvili Lasha Pareshishvili - 1 year ago 62
PHP Question

make limit of content when getting data from xml to php

Hello guys i'm getting data from xml to php and i want to make limit. for example get only 10 post down is a examples of my xml file and php code

This is xml file from where i'm getting data :

And there is a php code, so i'm getting data from xml file :

Answer Source

Put a counter inside your foreach loop and break when it reaches the limit you want. Something like

$countrer = 0;
   // your code here
  if($counter == X) break;

Where X the number of results you want.