Questions tagged as 'php'

2
answers

Find value inside an array

I have the following array: array (size=80) 0 => array (size=2) ‘cod_produto' => int 107 'valor' => float 20 1 =>
 array (size=2) ‘cod_produto' => int 109 'valor'...
asked by 03.05.2018 / 20:15
3
answers

How to remove the last character from the last value of an array

I have the following foreach: $items = ""; foreach ($_POST['termos'] as $item) { if(isset($item)){ $items = $items . $item . '+'; } } It returns me: Array ( [0] => 1-valor+ [1] => 2-valor+ [2] => 3-valor+ ) Q...
asked by 02.03.2015 / 02:05
1
answer

Anonymous function returns: syntax error, unexpected T_FUNCTION

When trying to use this function: <?php echo preg_replace_callback('~-([a-z])~', function ($match) { return strtoupper($match[1]); }, 'hello-world'); PHP returns this error:    Parse error: syntax error, unexpected T_FUNCTION...
asked by 17.02.2015 / 14:15
3
answers

How to optimize SQL queries containing DELETE related to SELECT?

$a = mysql_query("SELECT * FROM catalog_items where page_id='84'") or die(mysql_error()); while ($row = mysql_fetch_array($a)){ $base_item = $row['item_ids']; mysql_query("DELETE FROM items_rooms where base_item = '".$base_item."'") or...
asked by 24.03.2015 / 06:01
2
answers

Can I access a variable (not array) in PHP using index 0 as an array?

The case is as follows, I have a function that if something happens it creates an array with n numbers ($x[n]) and if it happens another it stores in a common variable with the same name ($x) . I know I can instead of storing...
asked by 16.03.2015 / 17:44
1
answer

How to save user-supplied date in MySQL?

I have a form that has a field where the user's date of birth is entered, this field has a datepicker that already returns the date in year, month, day format, this date is accessed through $_GET['birthdate'] its format is strin...
asked by 07.02.2015 / 13:51
2
answers

Routines in PHP, using return

In the PHP course I'm doing, we're now in routines, and we started using return, but I still do not quite understand it. <!DOCTYPE html> <html> <head> <link rel="stylesheet" href="_css/estilo.css"/> <meta cha...
asked by 25.05.2017 / 17:00
3
answers

Integer conversion into account rounding 0.1 [duplicate]

echo (int) ((0.1 + 0.7) * 10 ) By logic this should not return 8? 0.1 + 0.7 = 0.8 * 10 = 8 I'm returning 7. why?     
asked by 15.05.2017 / 16:23
2
answers

Simple XML Reader does not work correctly

I have used SimpleXMLReader to attempt to extract data from the following XML structure: <boutique> <produto num="228122907"> <id_produto><![CDATA[70427038]]></id_produto> <...
asked by 28.05.2017 / 21:34
2
answers

How to split a string in PHP?

I need to get two items on the magnet link magnet:?xt=urn:btih:0eb69459a28b08400c5f05bad3e63235b9853021&dn=Splinter.Cell.Blacklist-RELOADED&tr=udp%3A%2F%2Ftracker.com%3A80&tr=udp%3A%2F%2Ftracker.publicbt.com%3A80&tr=udp%3A%2F%2...
asked by 19.04.2014 / 02:25