Is there a way to get the feat Pack Flanking on a non Hunter class character? Keeping in mind that the teamwork feat requires both the character and companion to have it.
Give the animal companion a magic item granting the feat Pack Flanking
The challenging prerequisites for the teamwork feat Pack Flanking make the feat extremely difficult for most other classes besides the hunter (using the special ability hunter tactics) and the cavalier (using the special ability tactician) to use in conjunction with their animal companions.1 Magic items are the easiest way to circumvent the feat's overly restrictive prerequisites.
- The horsemaster's saddle (12,000 gp; 5 lbs.) and the sky marine's elite saddle (14,000 gp; 5 lbs.) which both grant the mount any teamwork feats possessed by the rider, even those teamwork feats with prerequisites no mount could ever meet.
- The ring of tactical precision (11,000 gp; 0 lbs.) is similar to the saddles, but for a lone feat and more trouble. Fun Fact: Most animals can't wear rings.
The character must still meet the prerequisites of the feat Pack Flanking in the first place, but these items mean the animal companion won't have to meet those same—and for the companion, likely impossible—prerequisites.
1 To have one's animal companion meet the feat's prerequisites, one could award the animal companion a wayfinder with the random resonant power of Combat Expertise (just pop in an ioun stone and roll the 21!) or maybe the 3rd-party weapon tooth of the narwhal (and never have inland adventures again!) then the animal companion could take the feat Animal Ally (convincing the GM that an animal with 4 Hit Dice is as if the creature possesses 4 levels, which it is) (note that there's probably a rule against nested companions somewhere), but, afterward, one must still somehow increase one's animal companion's Intelligence score to 13 (a difficult and expensive but not impossible task). This is not recommended. Just use a saddle or ring.
Animal companions never actually have the Pack Flanking feat (they don't qualify for it). First, the master takes the feat; then, the master finds a way to pretend his companion also has it. This is important to note.
Any character that has an animal companion can TAKE the Pack Flanking feat. The issue at this point is how to make it useful, which is almost certainly going to require multiclassing.
The two most obvious choices (besides your class that grants your animal companion) are Inquisitor and Cavalier, for their Solo Tactics and Tactician class features, respectively. These emulate in one way or another the Hunter's Hunter Tactics class ability by giving you a way to project your teamwork feats onto your animal companion. Cavalier can share the benefits with the whole party, but since the ones like Pack Flanking specifically call out "your companion creature", only your teammates with their own animal companions (and maybe mounts and eidolons) are likely to benefit. If you're only concerned with getting the benefits for yourself, the Inquisitor is probably the better bet. (Note that Solo Tactics ONLY applies to the Inquisitor; the animal companion would not gain the benefits of those teamwork feats.)
Personal optimization note #1:
I don't really suggest a three-level-dip into Inquisitor or Cavalier just to get Pack Flanking on your Ranger or Druid pet. However, I'm not against suggesting an Inquisitor or Cavalier, especially in a party with little melee, dip into a class that gives an animal companion early on and then use their free teamwork feats for stuff like Pack Flanking and Outflank.
And optimization note #2, which really isn't an answer to your question:
A three-level dip into Hunter is actually a pretty good option for a Ranger, though less so for a Druid. A Ranger might benefit from the Animal Focus, two bonus feats, and several orisons and a few 1st level ranger or druid spells permanently memorized in those Hunter slots, not to mention getting the first-level strong Ref and Fort saves again; all in exchange for an average of 3 hp and a single point of BAB. Granted, he also trades some of his own spellcasting, but look at the spells he gains. Six 0th level druid spells give him a ton of utility (create water, purify food and drink, detect magic, detect poison, light, mending...), and then four 1st level spells he can spontaneously cast from the ranger or druid lists? Whether you use it for a few extra entangles or some druid only CLW or burning disarm, it's useful. You might even consider a fourth level - just one more average hp (no more BAB loss) for two 2nd level spells, which could include flame blade and the like from the druid list, and improved empathic link.
In addition to Hey I Can Chan's answer, you could also permanency Anthropomorphic Animal so it can wear rings.
The downside is, you lose all non-bite attacks, all special attacks that rely on natural attacks, and all movement speeds except for their land speed.