<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet href="https://shkspr.mobi/blog/wp-content/themes/edent-wordpress-theme/rss-style.xsl" type="text/xsl"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	    xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	     xmlns:dc="http://purl.org/dc/elements/1.1/"
	   xmlns:atom="http://www.w3.org/2005/Atom"
	     xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	  xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>
<channel>
	<title>tip &#8211; Terence Eden’s Blog</title>
	<atom:link href="https://shkspr.mobi/blog/tag/tip/feed/" rel="self" type="application/rss+xml" />
	<link>https://shkspr.mobi/blog</link>
	<description>Regular nonsense about tech and its effects 🙃</description>
	<lastBuildDate>Sun, 02 Mar 2025 13:33:30 +0000</lastBuildDate>
	<language>en-GB</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>https://wordpress.org/?v=6.9.4</generator>

<image>
	<url>https://shkspr.mobi/blog/wp-content/uploads/2023/07/cropped-avatar-32x32.jpeg</url>
	<title>tip &#8211; Terence Eden’s Blog</title>
	<link>https://shkspr.mobi/blog</link>
	<width>32</width>
	<height>32</height>
</image> 
	<item>
		<title><![CDATA[Finding your most popular Tweets]]></title>
		<link>https://shkspr.mobi/blog/2020/05/finding-your-most-popular-tweets/</link>
					<comments>https://shkspr.mobi/blog/2020/05/finding-your-most-popular-tweets/#comments</comments>
				<dc:creator><![CDATA[@edent]]></dc:creator>
		<pubDate>Wed, 13 May 2020 11:02:57 +0000</pubDate>
				<category><![CDATA[/etc/]]></category>
		<category><![CDATA[HowTo]]></category>
		<category><![CDATA[tip]]></category>
		<category><![CDATA[twitter]]></category>
		<guid isPermaLink="false">https://shkspr.mobi/blog/?p=34963</guid>

					<description><![CDATA[Twitter&#039;s search interface has all sorts of lovely and obscure options.  My three favourites are &#34;min_retweets:&#34;, &#34;min_replies:&#34;, and &#34;min_faves:&#34;  Using those filters, you can create a search for Tweets which meet a certain threshold. For example, here are my Tweets which have been liked more than 500 times:  twitter.com/search?q=from:edent min_faves:500  Here are the ones which have been…]]></description>
										<content:encoded><![CDATA[<p>Twitter's search interface has all sorts of <a href="https://twitter.com/search-advanced">lovely and obscure options</a>.</p>

<p>My three favourites are "min_retweets:", "min_replies:", and "min_faves:"</p>

<p>Using those filters, you can create a search for Tweets which meet a certain threshold. For example, here are <em>my</em> Tweets which have been liked more than 500 times:</p>

<p><a href="https://twitter.com/search?q=from%3Aedent%20min_faves%3A500&amp;src=typed_query"><code>twitter.com/search?q=from:edent min_faves:500</code></a></p>

<p>Here are the ones which have been retweeted 300 times with at least 100 replies:</p>

<p><a href="https://twitter.com/search?q=from%3Aedent%20min_replies%3A100%20min_retweets%3A100&amp;src=typed_query&amp;f=live"><code>twitter.com/search?q=from%:edent min_replies:100 min_retweets:100</code></a></p>

<p>Of course, you don't have to do this for your own Tweets. You can perform the search on any term, or any user.</p>
<img src="https://shkspr.mobi/blog/wp-content/themes/edent-wordpress-theme/info/okgo.php?ID=34963&HTTP_REFERER=RSS" alt="" width="1" height="1" loading="eager">]]></content:encoded>
					
					<wfw:commentRss>https://shkspr.mobi/blog/2020/05/finding-your-most-popular-tweets/feed/</wfw:commentRss>
			<slash:comments>1</slash:comments>
		
		
			</item>
		<item>
		<title><![CDATA[Remove the first few lines from a string in PHP]]></title>
		<link>https://shkspr.mobi/blog/2020/03/remove-the-first-few-lines-from-a-string-in-php/</link>
					<comments>https://shkspr.mobi/blog/2020/03/remove-the-first-few-lines-from-a-string-in-php/#comments</comments>
				<dc:creator><![CDATA[@edent]]></dc:creator>
		<pubDate>Mon, 02 Mar 2020 08:31:07 +0000</pubDate>
				<category><![CDATA[/etc/]]></category>
		<category><![CDATA[HowTo]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[tip]]></category>
		<guid isPermaLink="false">https://shkspr.mobi/blog/?p=34332</guid>

					<description><![CDATA[Problem: I have a multiline string - not a file - and I want to remove the first few lines from it and keep the rest.  I found this surprisingly unintuitive. So these are notes in case I want to do it again. Feel free to suggest a better way!  Example  Given this input:  $str = &#34;Once upon\nA Time\nLived a big\nDragon\nCalled Cuthbert.&#34;;   I want the output to be:  &#34;Dragon\nCalled Cuthbert.&#34;  …]]></description>
										<content:encoded><![CDATA[<p>Problem: I have a multiline <code>string</code> - not a file - and I want to remove the first few lines from it and keep the rest.  I found this surprisingly unintuitive. So these are notes in case I want to do it again. Feel free to suggest a better way!</p>

<h2 id="example"><a href="https://shkspr.mobi/blog/2020/03/remove-the-first-few-lines-from-a-string-in-php/#example">Example</a></h2>

<p>Given this input:</p>

<pre><code class="language-php">$str = "Once upon\nA Time\nLived a big\nDragon\nCalled Cuthbert.";
</code></pre>

<p>I want the output to be:</p>

<pre><code class="language-php">"Dragon\nCalled Cuthbert."
</code></pre>

<p>That is, remove the first <em>X</em> lines in a string.</p>

<h2 id="exploding-kittens"><a href="https://shkspr.mobi/blog/2020/03/remove-the-first-few-lines-from-a-string-in-php/#exploding-kittens">Exploding kittens</a></h2>

<p>Using <a href="https://www.php.net/manual/en/function.explode.php"><code>explode()</code></a> converts a <code>string</code> into an <code>array</code> based on a delimiter character.</p>

<blockquote><p>If <code>limit</code> is set and positive, the returned <code>array</code> will contain a maximum of <code>limit</code> elements with the last element containing the rest of <code>string</code>.</p></blockquote>

<p>This code removes the first <strong>three</strong> lines and keeps the rest</p>

<pre><code class="language-php">$str = explode("\n", $str, 4)[3];
</code></pre>

<p>Here's a way to visualise what's going on:</p>

<pre><code class="language-php">$str = "1\n2\n3\n4\n5\n6";
print_r(explode("\n", $str, 4));
</code></pre>

<p>Outputs:</p>

<pre><code class="language-php">Array
(
    [0] =&gt; 1
    [1] =&gt; 2
    [2] =&gt; 3
    [3] =&gt; 4\n5\n6
)
</code></pre>

<h2 id="what-not-to-do"><a href="https://shkspr.mobi/blog/2020/03/remove-the-first-few-lines-from-a-string-in-php/#what-not-to-do">What not to do...</a></h2>

<ul>
<li>Loop through the string, counting the instances of <code>\n</code> and then substringing based on that position.</li>
<li>Write the string to a file and then <a href="https://www.php.net/manual/en/function.fgets.php">read it line by line</a>.</li>
</ul>
<img src="https://shkspr.mobi/blog/wp-content/themes/edent-wordpress-theme/info/okgo.php?ID=34332&HTTP_REFERER=RSS" alt="" width="1" height="1" loading="eager">]]></content:encoded>
					
					<wfw:commentRss>https://shkspr.mobi/blog/2020/03/remove-the-first-few-lines-from-a-string-in-php/feed/</wfw:commentRss>
			<slash:comments>1</slash:comments>
		
		
			</item>
	</channel>
</rss>
