Skip to content

Tag: php

How to extract price from given url using Xpath?

From a given url I want to extract some detail from it like title, price. For the title, it works fine with this code: But I wonder how to extract price($) using xpath? Is there any way to solve this? Answer This will find <p class=”price right s-cf”>US$160000</p> The contains is doing…

Remove first result in JSON

I’m using GoogleCharts. I have a problem with the first result. I need to remove the first result in “rows”. I tried with array_shift but I got an error. $q = Database::connect()->prepare(“SELECT …

Setting Cookie on click

I’m having an issue creating / setting a cookie on the click of a link, is there a proper way to do this? Either PHP or Javascript is fine. Obviously both JS and PHP wouldn’t exist in the same instance it was just to show what I have. Answer You can’t mix JavaScript and PHP. By the time your…

How to find average from array in php?

Example: Actually how to find average value from this array excluding empty. please help to resolve this problem. Answer first you need to remove empty values, otherwise average will be not accurate. so DEMO More concise and recommended way See here