|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2004-08-04 02:12 UTC] borivoje at gmail dot com
Description: ------------ http://www.code-experts.com/listTopic.asp?tid=44 Reproduce code: --------------- echo $poss . ' - positions<br/>'; $paragraphs = explode("\n",$textToReplace); $ord = 0; while (list($breakIndex,$breakToReplace) = each($paragraphs)) { echo $poss . "<br/>"; // <------ here echo $breakIndex . "-" . $ord . "<br/>"; if ($breakIndex % $poss = 0) { $ord = $ord + 1; if ($ord = 1) $paragraphs[$breakIndex] = "<p class='news_preview'>". $breakToReplace . "<img class='news_pic_r' src='$picDir/$article->picturePath1'/></p>"; if ($ord = 2) $paragraphs[$breakIndex] = "<p class='news_preview'>". $breakToReplace . "<img class='news_pic_l' src='$picDir/$article->picturePath2'/></p>"; if ($ord = 3) $paragraphs[$breakIndex] = "<p class='news_preview'>". $breakToReplace . "<img class='news_pic_r' src='$picDir/$article->picturePath3'/></p>"; } else { $paragraphs[$breakIndex] = "<p class=\"news_preview\">". $breakToReplace ."</p>"; } } Expected result: ---------------- All ones (1 int) Actual result: -------------- First one then 0-oes PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Thu Nov 06 21:00:02 2025 UTC |
<?php $string = "helo,here,is,an,example"; $paragraphs = explode(",", $string); $position = 10; while (list($index, $thing) = each($paragraphs)) { echo $position; // here anything... } ?>