$link) { $html = file_get_contents($link); $bookmarkStart = strpos($html, '"bookmarkCount":'); if ($bookmarkStart !== false) { $bookmarkEnd = strpos($html, ',', $bookmarkStart); if ($bookmarkEnd !== false) { $bookmarkCount = substr($html, $bookmarkStart + 16, $bookmarkEnd - $bookmarkStart - 16);}} $likeStart = strpos($html, '"likeCount":'); if ($likeStart !== false) { $likeEnd = strpos($html, ',', $likeStart); if ($likeEnd !== false) { $likeCount = substr($html, $likeStart + 12, $likeEnd - $likeStart - 12);}} $commentStart = strpos($html, '"commentCount":'); if ($commentStart !== false) { $commentEnd = strpos($html, ',', $commentStart); if ($commentEnd !== false) { $commentCount = substr($html, $commentStart + 15, $commentEnd - $commentStart - 15);}} echo "
{$link} »
Bookmark Count: {$bookmarkCount}, Like Count: {$likeCount}, Comment Count: {$commentCount}
\n";}} ?>

{$artLink}
\n"; $numLinks++; // Increment the link counter if ($numLinks >= 4) { return; // Break after 4 links are found } } else { foreach ($artworks as $artId => $art) { $artLink = "https://www.pixiv.net/artworks/{$artId}"; echo "{$artLink} »
\n"; $numLinks++; // Increment the link counter if ($numLinks >= 4) { return; // Break after 4 links are found } } } // Display the number of links found within the div echo ""; } else { echo "No artworks found for the given user."; } } // Usage example $userId = isset($_GET['userId']) ? $_GET['userId'] : '75406576'; $random = isset($_GET['random']); getPixivUserArt($userId, $random); ?>