Get value from Array?

I have this array:

Array
(
[tags] => Health, Insurance, Health, copayment, coverage, networks
[tid] => 244
)
Array
(
[tags] => Using, Debit, card, inplace, Credit, card
[tid] => 292
)
Array
(
[tags] => Business, insurance, business, insurance, Business, could
[tid] => 328
)
Array
(
[tags] => What, the, sales, tax, the, United, States, USA
[tid] => 919
)
Array
(
[tags] => Best, health, insurance, companies, health, companies
[tid] => 1040
)
Array
(
[tags] => Make, money, from, home, spending, decent
[tid] => 1108
)
Array
(
[tags] => How, make, Million, one, year
[tid] => 1258
)
Array
(
[tags] => How, get, into, freelance, marketing
[tid] => 1260
)
Array
(
[tags] => Custom, code, modefication, will, pay
[tid] => 2706
)
Array
(
[tags] => The, Blue, Crown, Capital, Management, Specialists, Mortgage, Refinancing
[tid] => 1320
)
Array
(
[tags] => What, general, Marketing, means, general, means
[tid] => 1369
)
Array
(
[tags] => How, much, does, copyrights, cost
[tid] => 1397
)
Array
(
[tags] => Black, Friday, What, Does, Mean
[tid] => 1572
)
Array
(
[tags] => World, Wealthiest, People, Top, Billionaires, List
[tid] => 1594
)
Array
(
[tags] => favorite, CPA, network, apart, money, networks
[tid] => 1677
)
Array
(
[tags] => What, are, best, marketing, strategies, tips, and, tricks
[tid] => 1858
)
Array
(
[tags] => What, the, most, profitable, businesses, start
[tid] => 1937
)
Array
(
[tags] => How, make, money, from, home
[tid] => 2141
)
Array
(
[tags] => Selling, used, cars, business, dealers, about
[tid] => 2145
)
Array
(
[tags] => How, become, rich, trading, Forex
[tid] => 2456
)
Array
(
[tags] => Digital, Marketing, digital, marketing, please, share
[tid] => 2509
)
Array
(
[tags] => What, quotLink, Wheelquot, black, hat, technique
[tid] => 2709
)

Each array has it’s own tid. How do I fetch out of there a tag that corresponds on some X tid!

I mean if the tid is this fetch from array this tag!

I would be tempted to try and extract the source into the following format and use in_array(…);:

$source = array
(
  2145 => "Selling, used, cars, business, dealers, about",
  2509 => "Digital, Marketing, digital, marketing, please, share",
  2709 => "What, quotLink, Wheelquot, black, hat, technique",
  ...
);

Failing that try this verbose approach:


$source = array
(
	Array
	(
	"tags" => "Health, Insurance, Health, copayment, coverage, networks",
	"tid" => 244
	),
	Array
	(
	"tags" => "Using, Debit, card, inplace, Credit, card",
	"tid" => 292
	),
	Array
	(
	"tags" => "Business, insurance, business, insurance, Business, could",
	"tid" => 328
	),
);
// echo '<pre>'; print_r($source); echo '</pre>';

$search = 292;
foreach($source as $src => $item) {
	if( $search === $item['tid'] ) {
		echo 'Found: '
				. $item['tid'] 
				.  ' => '
				. $item['tags'];
	}
}

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.