I started to apologize for writing three posts on this and promising not to do any more but I reconsidered. This is my site. I’ll write whatever I want. Skip it if it bores you or exile me from your feed reader.1
Alan’s comment got me thinking that using spreadsheet formulas was not necessary and it felt awkward to me anyway. So I figured out how to do it all in the php. I’ll include the relevant portion of the code below. You can get the whole thing here.
//$caption gets all the text associated with the instagram post $caption = $media->caption->text; $filter = $media->filter; //$hashcount looks at $caption and counts how many times it finds a # $hashcount = substr_count($caption, '#'); //$hashtrue looks at $hashcount and if it's >0 it returns true $hashtrue = (boolval($hashcount) ? 'true' : 'false'); //same pattern here counting @ instead $atcount = substr_count($caption, '@'); $attrue = (boolval($atcount) ? 'true' : 'false'); //add the results to the CSV array_push($list, $username . '?' . $likes . '?' . $comments . '?' . $link . '?' . $caption . '?' . $filter . '?' . date(DATE_RFC2822) . '?' . $hashtrue . '?' . $hashcount . '?' . $attrue . '?' .$atcount) ;