$tagArray = array(); $xtag = array(); $ytag = array(); $tagKeywords = array(); $fontSize = array(); if (!simplexml_load_string($keywords)) { //no keywords; //file_put_contents("testfile.txt", "no keywords", FILE_APPEND | LOCK_EX); //file_put_contents("testfile.txt", "\r\n", FILE_APPEND | LOCK_EX); } else { $words = simplexml_load_string($keywords); $countKey = 0; foreach ($words->children() as $key) { if ($key['word'] != "") { $keyword = new Keyword(); $keyword->initializeMembers($key); //$keyword->printKeyword(); $tagArray[$countKey] = $keyword; $countKey++; } } for ($i = 0; $i < count($tagArray); $i++) { $xtag[$i] = $tagArray[$i]->x; $ytag[$i] = $tagArray[$i]->y; $tagKeywords[$i] = $tagArray[$i]->keyword; $fontSize[$i] = $tagArray[$i]->size; //file_put_contents("testfile.txt", $tagKeywords[$i], FILE_APPEND | LOCK_EX); //file_put_contents("testfile.txt", "**", FILE_APPEND | LOCK_EX); //file_put_contents("testfile.txt", $xtag[$i], FILE_APPEND | LOCK_EX); //file_put_contents("testfile.txt", "**", FILE_APPEND | LOCK_EX); //file_put_contents("testfile.txt", $ytag[$i], FILE_APPEND | LOCK_EX);