JSON:查找内容并提取信息

时间:2019-01-21 23:19:55

标签: php json curl foreach

我有一个如下的URL JSON数组:sOdd = "The cat jumped over the moon very quickly." sEven = "The cat jumped over the moon very quickly now." def split_on_delim_mid(s, delim=" "): delim_indexes = [ x[0] for x in enumerate(s) if x[1]==delim ] # [3, 7, 14, 19, 23, 28, 33] # Select the correct number from delim_indexes middle = len(delim_indexes)/2 if middle % 2 == 0: middle_index = middle else: middle_index = (middle-.5) # Return the separated sentances sep = delim_indexes[int(middle_index)] return s[:sep], s[sep:] split_on_delim_mid(sOdd) # ('The cat jumped over', ' the moon very quickly.') split_on_delim_mid(sEven) # ('The cat jumped over the', ' moon very quickly now.')

我想搜索用户选择的类别ID并打印该类别的名称,问题是我的PHP代码无法正常工作。

这是我已经尝试过的:

[{"category_id":"57","category_name":"Martin","parent_id":0},{"category_id":"18","category_name":"Intel","parent_id":0}, etc

0 个答案:

没有答案