--- title: Learn About Php Loops localeTitle: تعرف على Php Loops --- الحلقات هي كتل من التعليمات البرمجية التي تنفذ عدد محدد من المرات. استخدام الحلقات يقلل عدد أسطر التعليمات البرمجية. تعمل PHP مع 4 أنواع مختلفة من الحلقات: * حائط اللوب * هل ... في حين حلقة * لحلقة * حلقة foreach ## حائط اللوب تستمر حلقة `while` في التنفيذ طالما أن الشرط المحدد صحيح. \`فب ``Example: ```php ``` ``` Output: x=1 x=2 x=3 ``` ## Do...while loop In the `do...while` loop the block of code is executed before the condition is checked. ```php ``` Example: ```php ``` ``` Output: x=1 x=2 x=3 x=4 ``` ## For loop The `for` loop is used when the number of times the block is to be executed is known in advance. ```php ``` Example: ```php ``` ``` Output: x=1 x=2 x=3 x=4 ``` ## Foreach loop The `foreach` loop helps in traversing through arrays. ```php ``` Example: ```php ``` ``` Output: One Two Three ``